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.
Steps
1
Create the app and install packages
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
chainsis the default, so testnet comes first while you build. http()with no URL uses the chain’s public RPC:https://rpc.bohr.lifefor testnet andhttps://rpc.botchain.aifor mainnet.injected()connects to browser wallets such as MetaMask.- The
Registerblock gives every hook full types for your chains.
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
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
Type error: chainId is not assignable
Type error: chainId is not assignable
The
declare module "wagmi" block is missing, or the file isn’t included in your tsconfig.json. Add it to src/wagmi.ts.WagmiProviderNotFoundError
WagmiProviderNotFoundError
A component uses a wagmi hook outside
<Providers>. Make sure <App /> is inside it in main.tsx.The block number never loads
The block number never loads
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.