From ce7a27d539d5d6a8faa0e2d4dab2955e1fc865d8 Mon Sep 17 00:00:00 2001 From: Obada1989 <181800036+Obada1989@users.noreply.github.com> Date: Tue, 19 Nov 2024 08:06:43 +0300 Subject: [PATCH] Update README.md Fixed --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index effe0d8..7c83874 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,50 @@ If that process is too involved for you, you can always open a thread on the [Me For help on formatting your submission correctly, check out these guidelines: - [Format your Markdown](https://docs-template.consensys.net/contribute/format-markdown) correctly. +import Onboard from '@web3-onboard/core' +import injectedModule from '@web3-onboard/injected-wallets' +import { ethers } from 'ethers' + +const MAINNET_RPC_URL = 'https://mainnet.infura.io/v3/' + +const injected = injectedModule() + +const onboard = Onboard({ + wallets: [injected], + chains: [ + { + id: '0x1', + token: 'ETH', + label: 'Ethereum Mainnet', + rpcUrl: MAINNET_RPC_URL + }, + { + id: '0x2105', + token: 'ETH', + label: 'Base', + rpcUrl: 'https://mainnet.base.org' + } + ] +}) + +const wallets = await onboard.connectWallet() + +console.log(wallets) + +if (wallets[0]) { + // create an ethers provider with the last connected wallet provider + const ethersProvider = new ethers.providers.Web3Provider(wallets[0].provider, 'any') + // if using ethers v6 this is: + // ethersProvider = new ethers.BrowserProvider(wallet.provider, 'any') + + const signer = ethersProvider.getSigner() + + // send a transaction with the ethers provider + const txn = await signer.sendTransaction({ + to: '0x', + value: 100000000000000 + }) + + const receipt = await txn.wait() + console.log(receipt) +}