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

Viem

Integrate with Viem

Connect wallet to Flow EVM

// page.tsx

import { createWalletClient, custom, http } from 'viem'
import { flowMainnet, flowTestnet } from 'viem/chains'

const WalletConnect = () => {
    
  // connect wallet function
  const connectWallet = async () => {
    try {
      const client = createWalletClient({
        chain: flowMainnet,
        transport: custom(flowWalletProvider!)
      })

      // request user to connect wallet
      const [address] = await client.getAddresses()
      const chainId = await client.getChainId(); // get chain id

    } catch (err: any) {
      console.log('Connect wallet failed:' + err.message);
    }
  };
  
  return (
      <div>
         <button onClick={connectWallet}>Connect Wallet</button>
      <div/>
  )
}

PreviousWeb3jsNextWeb3-Onboard

Last updated 3 months ago

See more detail on

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