UNPKG

saepenatus

Version:

Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, mul

56 lines (40 loc) 1.21 kB
# Getting Started ## Installation Install the core Onboard library and the injected wallets module to support browser extension and mobile wallets: ```bash copy npm i @web3-onboard/core @web3-onboard/injected-wallets ``` ## Quick Start Then initialize in your app: ```js copy lineNumbers 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/<INFURA_KEY>' const injected = injectedModule() const onboard = Onboard({ wallets: [injected], chains: [ { id: '0x1', token: 'ETH', label: 'Ethereum Mainnet', rpcUrl: MAINNET_RPC_URL } ] }) 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') 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) } ```