Skip to main content
In this guide you build a React component that connects a browser wallet, notices when it’s on the wrong network and asks the wallet to switch to BOT Chain testnet.
Everything on this page uses testnet (chain 968). Get free test tokens from the faucet.

What you’ll build

A ConnectWallet component with three states: not connected, connected to the wrong network, and connected to BOT Chain testnet.

Prerequisites

  • A React app with wagmi set up. See Set up wagmi.
  • A browser wallet such as MetaMask.

Steps

1

Write the component

src/ConnectWallet.tsx
Notes on the wagmi 3 API:
  • useConnection replaces useAccount, which is deprecated in wagmi 3.
  • useConnectors lists the connectors from your config. With injected() you get one button per detected browser wallet.
  • Action hooks return a mutation. Call .mutate(...), and read .isPending and .error from the same object.
  • chainId from useConnection is the wallet’s chain, which can be one your app doesn’t support. That’s how you detect the wrong network.
2

Render it

src/App.tsx

Verify it worked

  1. Run npm run dev and open the app. You see a Connect button for your wallet.
  2. Click it and approve in the wallet. If the wallet is on another network, you see Wrong network.
  3. Click Switch network. The wallet asks to switch, or to add BOT Chain Testnet if it doesn’t know it yet. Approve it.
  4. The component shows your address.

Troubleshooting

No injected wallet was found. Install MetaMask or another browser wallet and reload the page.
Some wallets can’t add chains from a dapp. Add BOT Chain Testnet by hand using the values in Connect a wallet, then try again.
The user closed or rejected the wallet popup. Nothing changed; they can click the button again.

Next steps

Read contract state

Show the connected user’s balances.

Send transactions

Write to a contract and wait for the receipt.
Last modified on October 3, 2026