Skip to main content
In this guide you add wagmi to a React app and configure it for BOT Chain testnet and mainnet, so the rest of the frontend guides can read and write contracts.
Everything on this page uses testnet (chain 968). Get free test tokens from the faucet.

What you’ll build

A React app that shows the current BOT Chain block number, updated live, with wagmi ready for wallet and contract hooks.

Prerequisites

  • Node.js 22 or later.
  • Basic React knowledge.
This guide uses Vite. Any React setup works; only the entry file changes.

Steps

1

Create the app and install packages

Tested with wagmi 3.7.7, viem 2.57.2, @tanstack/react-query 5.104.0, react 19.3.0 and @uzolabs/sdk 0.2.0.@uzolabs/sdk provides the BOT Chain chain objects. If you’d rather not add it, define the chains yourself with viem’s defineChain, as shown in Build your first dApp.
2

Create the wagmi config

src/wagmi.ts
  • The first chain in chains is the default, so testnet comes first while you build.
  • http() with no URL uses the chain’s public RPC: https://rpc.bohr.life for testnet and https://rpc.botchain.ai for mainnet.
  • injected() connects to browser wallets such as MetaMask.
  • The Register block gives every hook full types for your chains.
The chain objects also include BOTScan as the block explorer and the Multicall3 address, which wagmi uses to batch reads.
3

Add the providers

wagmi uses TanStack Query for caching, so both providers wrap your app.
src/providers.tsx
4

Use them in the entry file

src/main.tsx
5

Show the block number

src/App.tsx

Verify it worked

Open the URL Vite prints. You should see Chain 968, block followed by a number that goes up every few seconds. There is no WebSocket on the public RPC, so watch: true polls over HTTP.

Troubleshooting

The declare module "wagmi" block is missing, or the file isn’t included in your tsconfig.json. Add it to src/wagmi.ts.
A component uses a wagmi hook outside <Providers>. Make sure <App /> is inside it in main.tsx.
Open the browser’s network tab. If calls to the RPC fail, try again: the public RPC sometimes drops requests. For production, use your own RPC URL in http("https://...").

Next steps

Connect a wallet

Connect, detect the wrong network and switch.

Read contract state

Read balances and batch reads.
Last modified on October 2, 2026