@instadapp/avocado-provider
v0.0.13
Published
## Usage Install package:
Downloads
17
Keywords
Readme
@instadapp/avocado-provider
Usage
Install package:
# npm
npm install @instadapp/avocado-provider
# yarn
yarn add @instadapp/avocado-provider
# pnpm
pnpm install @instadapp/avocado-provider
Import:
import { AvocadoProvider } from "@instadapp/avocado-provider";
import { ethers } from "ethers";
const avocado = new AvocadoProvider({
projectId: "42e9e3b646c9102371bd147b3e960c39", // WalletConnect project ID
chains: [1, 137],
})
avocado.on("connect", (info) => {
console.log(info)
})
avocado.on("chainChanged", (chainId) => {
console.log(chainId)
})
avocado.on("accountsChanged", (accounts) => {
console.log(accounts)
})
avocado.on("disconnect", (error) => {
console.log(error)
})
const accounts = await avocado.enable() // or `await avocado.request({ method: "eth_requestAccounts" })`
await avocado.request({
method: "avocado_getOwner",
})
// ethers v5 integration
const provider = new ethers.providers.Web3Provider(avocado)
const signer = provider.getSigner()
const tx = await signer.sendTransaction({
to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E",
value: 42,
})