Skip to main content

wagmi + React

wagmi is the standard React library for EVM wallet connections and contract interactions. This page covers the essential patterns for a Sei frontend: configuration, connecting and disconnecting a wallet, reading balances, and writing to contracts. For Node.js scripts and backend services, see the viem Quickstart instead.

Try it live

The hooks below (useBlockNumber and useBalance) are thin wrappers over JSON-RPC reads. These snippets send the same reads directly to Sei Mainnet, without a wallet connection. They show the data that your components will render.

Install

Configuration

Configure wagmi with Sei Mainnet, Sei Testnet, and your preferred wallet connectors:

Provider setup

Wrap your dApp with WagmiProvider and QueryClientProvider:

Connecting a wallet

Reading the native SEI balance

Reading a contract

Writing to a contract

Use useWriteContract for transactions that change state. Use useWaitForTransactionReceipt to track confirmation:
Sei has instant finality, so useWaitForTransactionReceipt resolves as soon as the transaction is included in a block. A single confirmation is final. See Finality.

Watching the connected chain