wagmi
React hooks library for Ethereum interactions and wallet connections.
3. Used by agents' projects
Dependency in 18 public GitHub projects set up for AI coding agents that we scanned (0.3%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
wagmi.sh/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What wagmi does
wagmi wraps Viem's blockchain calls in React Hooks and routes them through TanStack Query, so the chains in your config and your contract ABIs become TypeScript types and repeated RPC reads are cached and deduplicated.
wagmi popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How wagmi is used
- wagmi is a dependency in 18 of the 6,258 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750); counting those, it appears in 778 projects, and what it is used with below comes from all of them.
- The most used alternative in our scan is viem (47 projects).
- Projects that use it most often also use viem (98.5%), TanStack Query (77.8%), React (91.4%).
By coding agent
Often used with
wagmi in practice
Strengths
The maintainers write that you "often just need to provide an ABI". wagmi then gives you autocomplete, type inference and static validation, so type errors surface before users hit them.
You can register your config with a <code>declare module 'wagmi'</code> block or pass it through a hook's config property. After that, <code>useBlockNumber</code> only accepts the IDs of the configured chains. In the docs example, <code>chainId: 123</code> is a type error because only Mainnet and Sepolia are set up.
The Why page warns that careless fetching can "cost thousands in RPC compute units." wagmi's answer is TanStack Query, which brings caching, deduplication and persistence.
The comparison page on wagmi's docs site lists two more pros for wagmi: auto-refresh on wallet, block and network changes, and multicall support.
Watch out for
The maintainers say the APIs "might seem more verbose at first." They present this as the price of small building blocks that are easy to move, change and remove.
Setup does not stop at installing wagmi. You also install Viem and TanStack Query, then nest a <code>QueryClientProvider</code> with its own <code>QueryClient</code> inside <code>WagmiProvider</code>.
The comparison page on wagmi's docs site lists one con for wagmi: it has fewer built-in connectors than web3-react. The page says it aims to be unbiased and invites readers to suggest changes.
More about wagmi
Funding
- GitHub Sponsors: https://github.com/wevm
- Own page: https://drips.network/wevm.eth
- 16 GitHub sponsors
Packages around it
- viem: Ethereum interface wagmi runs on
- @tanstack/react-query: Caching and request layer
- react: UI library for the hooks
- @rainbow-me: Wallet connect UI
- next: React framework
- ethers: Ethereum library, adapters in docs
Alternatives
wagmi This page
TypeScript interface for Ethereum with type-safe interactions.
Get started
Install it.
npm install wagmiRules for your agent
## wagmi
- Install the peers explicitly: `wagmi viem@2.x @tanstack/react-query`. For new projects, the docs recommend `create wagmi` instead.
- Build the config with `createConfig`, and give every chain in `chains` a matching entry in `transports` (for example `[mainnet.id]: http()`).
- Wrap the app in `WagmiProvider`, then put `QueryClientProvider` with a `new QueryClient()` inside it. Hooks only work in components under both providers.
- Register the config (`declare module 'wagmi' { interface Register { config: typeof config } }`) or pass the hook config property, so that `chainId` is typed to the configured chains.
- In query hooks such as `useEnsName`, handle the `status` values `'pending'` and `'error'` before you render `data`.
- Check the installed major version. 2.x docs live at 2.x.wagmi.sh, and there are migration guides for v1 to v2 and v2 to v3.
- For Markdown docs written for language models, read `https://wagmi.sh/llms.txt` or `/llms-full.txt`.