Skip to content

Commit

Permalink
Update README.md file
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI committed Aug 5, 2023
1 parent fb8b770 commit 64f81cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 48 deletions.
57 changes: 11 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,53 +81,18 @@ await erc20.transfer("0x910E413DBF3F6276Fe8213fF656726bDc142E08E", 69420)
```

```ts
import { AvocadoSafeProvider } from '@instadapp/avocado'
import { ethers } from 'ethers'
import Web3 from 'web3'

const ethereum = new AvocadoSafeProvider({ chainId: 137 }) // window.etherem
await ethereum.enable()
import { Wallet, ethers } from "ethers"

const provider = new ethers.providers.Web3Provider(ethereum, "any")
const web3 = new Web3(ethereum)

console.log(await provider.listAccounts())
console.log(await provider.getBalance("0x910E413DBF3F6276Fe8213fF656726bDc142E08E"))
console.log(await web3.eth.getBalance("0x910E413DBF3F6276Fe8213fF656726bDc142E08E"))
```

```ts
import { AvocadoInjectedConnector } from '@instadapp/avocado'
const wallet = new Wallet(
"PK_HERE",
new ethers.providers.JsonRpcProvider("https://rpc.avocado.instadapp.io")
)

const avocado = new AvocadoInjectedConnector({ chainId: 137 })
const safe = createSafe(wallet)

const { activate } = useWeb3() // web3-react v6 or @instadapp/vue-web3
await activate(avocado)
await safe.sendTransaction({
to: "0x910E413DBF3F6276Fe8213fF656726bDc142E08E",
value: 0,
chainId: 137
})
```

```ts
import { AvocadoSafeProvider } from '@instadapp/avocado'

const providerOptions = {
'custom-avocado': {
display: {
logo: SVGavocado,
name: 'Avocado',
description: '',
},
package: AvocadoSafeProvider,

options: {
chainId: 137,
},

connector: async (ProviderPackage, options) => {
const provider = new ProviderPackage(options)

await provider.enable()

return provider
},
}
}
```
9 changes: 7 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from "ethers"
import { Wallet, ethers } from "ethers"
import { createSafe } from "./src"

const provider = new ethers.providers.Web3Provider(window.ethereum, "any")
Expand All @@ -7,6 +7,11 @@ await provider.send("eth_requestAccounts", []);

const safe = createSafe(provider.getSigner())

// const safe = createSafe(new Wallet(
// "PK_HERE",
// new ethers.providers.JsonRpcProvider("https://rpc.avocado.instadapp.io")
// ))

document.querySelector('#app')!.innerHTML = `<button> Send Tx </button>`

document.querySelector("#app button")!.addEventListener('click', async () => {
Expand All @@ -19,4 +24,4 @@ document.querySelector("#app button")!.addEventListener('click', async () => {
chainId: 137
})
)
})
})

0 comments on commit 64f81cf

Please sign in to comment.