Flow Wallet
  • 👋Welcome to Flow Wallet
  • Ecosystem Primers
    • ⭐Flow Reference Wallet Primer
  • FAQ
    • ❓FAQ
  • Features
    • ⛓️Account Linking
    • 🔌WalletConnect
    • 📖Human Readable Transactions
    • 💚Flow Client Library (FCL)
    • 🔓Secure Enclave
    • 🦺Account Recovery
  • Ecosystem Development
    • 🛠️Ecosystem Developer Grants
    • 🔌Integrate Flow EVM with Web3 SDKs
      • Wagmi
      • Rainbowkit
      • Etherjs
      • Web3js
      • Viem
      • Web3-Onboard
      • MIPD
      • Others SDKs
  • Download
    • 📲Download
  • Open Source
    • 💽Open Source
  • Tutorial
    • 🔐Mobile Wallet Backup Guide
    • 💸Move Assets between Flow and EVM
    • 📱Mobile Wallet Restore Guide
    • 💻Extension Wallet Backup Guide
    • 🖥️Extension Wallet Restore Guide
    • 🔁Extension Update Guide
    • 🪙FLOW wallet init token guide
    • 💾Extension Private Key and Seed Phrase Guide
    • ⛵Mobile Wallet Export Log Guide
Powered by GitBook
On this page
  1. Ecosystem Development
  2. Integrate Flow EVM with Web3 SDKs

Web3-Onboard

Integrate with Web3-Onboard

Connect wallet to Flow EVM

// page.tsx
import Onboard from '@web3-onboard/core'
import injectedModule from '@web3-onboard/injected-wallets'
import { ethers } from 'ethers'

const WalletConnect = () => {
    
    // config flow network
    const onboard = Onboard({
    wallets: [injected],
    chains: [
      {
        id: '747',
        token: 'FLOW',
        label: 'Flow EVM Mainnet',
        rpcUrl: 'https://mainnet.evm.nodes.onflow.org'
      },
      {
        id: '545',
        token: 'FLOW',
        label: 'Flow EVM Testnet',
        rpcUrl: 'https://testnet.evm.nodes.onflow.org'
      }
    ]
  })
  
   // connect wallet
  const connectWallet = async () => {

      // request wallet connect
      const wallets = await onboard.connectWallet()

      if (wallets[0]) {
        setAccount(wallets[0].address)
        // create an ethers provider with the last connected wallet provider
        const ethersProvider = new ethers.BrowserProvider(flowWalletProvider, 'any')

        const { address } = wallets[0].accounts[0]

        const chainId = wallets[0].chains[0].id
        const balance = await ethersProvider.getBalance(address)

      }
  };
  
  return (
    <div>
       <button onClick={connectWallet}>Connect Wallet</button>
    <div/>
  )
}

PreviousViemNextMIPD

Last updated 4 months ago

See more detail on

🔌
https://github.com/Outblock/web3-onboard-flow-evm-demo