From 64f81cff2f2da087333b27eedf5611f827cbfbb5 Mon Sep 17 00:00:00 2001 From: Georges KABBOUCHI Date: Sat, 5 Aug 2023 17:24:03 +0300 Subject: [PATCH] Update README.md file --- README.md | 57 +++++++++++-------------------------------------------- index.ts | 9 +++++++-- 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 44d995b..32c67a0 100644 --- a/README.md +++ b/README.md @@ -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 - }, - } -} -``` \ No newline at end of file diff --git a/index.ts b/index.ts index 6176555..833fa2f 100644 --- a/index.ts +++ b/index.ts @@ -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") @@ -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 = `` document.querySelector("#app button")!.addEventListener('click', async () => { @@ -19,4 +24,4 @@ document.querySelector("#app button")!.addEventListener('click', async () => { chainId: 137 }) ) -}) \ No newline at end of file +})