wagmi

Implement type-safe Ethereum dApp frontends using wagmi v2 React hooks and viem.

1|1|Updated May 21, 2026
One-click install
npx skills add https://github.com/naruto11eth/cryptoskills --skill wagmi-naruto11eth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wagmi
Source: https://github.com/naruto11eth/cryptoskills/tree/main/skills/wagmi
Command: npx skills add https://github.com/naruto11eth/cryptoskills --skill wagmi-naruto11eth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents trained on pre-2024 data generate outdated wagmi v1 code with removed APIs like WagmiConfig, useContractRead, and usePrepareContractWrite, causing broken builds and runtime errors in Ethereum dApp frontends. ## Core Features & Use Cases - wagmi v2 Hook Patterns: Correct usage of useAccount, useConnect, useReadContract, useWriteContract, useSimulateContract, useWaitForTransactionReceipt, useSwitchChain, and ENS hooks with TanStack Query integration. - Wallet Connection & Connectors: Configuration of injected, WalletConnect, Coinbase Wallet, MetaMask, and Safe connectors with EIP-6963 multi-injected provider discovery. - Production Patterns: SSR/Next.js hydration with cookie storage, approve-then-execute DeFi flows, multicall batched reads, error parsing for contract reverts, and multi-chain transport configuration. - Use Case: Build a Next.js dApp that connects MetaMask and WalletConnect, reads USDC balances across Ethereum, Arbitrum, and Base, and executes an ERC-20 approve-then-deposit flow with pre-flight simulation. ## Quick Start Ask the agent to set up a wagmi v2 project with WagmiProvider, QueryClientProvider, a wallet connect button, and an ERC-20 balance read for a connected account.

Frequently Asked Questions about wagmi

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect a wallet in wagmi v2?

Wrap your app in WagmiProvider and QueryClientProvider, then use useConnect to access connectors and call connect({ connector }). Configure connectors like injected(), walletConnect(), and coinbaseWallet() in createConfig.

How to read a smart contract with wagmi React hooks?

Use useReadContract with address, abi, functionName, and args. The ABI must be declared with as const for type inference, and uint256 return values come back as bigint, never JavaScript number.

What changed from wagmi v1 to v2?

WagmiConfig became WagmiProvider, useContractRead became useReadContract, useContractWrite became useWriteContract, and usePrepareContractWrite was removed in favor of useSimulateContract. TanStack Query is now mandatory for caching.

Does wagmi work with Next.js server-side rendering?

Yes, set ssr: true in createConfig and use cookieStorage via createStorage. In the root layout, call cookieToInitialState with the request cookie header and pass it to WagmiProvider to avoid hydration mismatches.

Why do I get 'No QueryClient set' error in wagmi?

wagmi v2 delegates all caching to TanStack Query, so every hook throws without a QueryClientProvider. Wrap your component tree in both WagmiProvider and QueryClientProvider with a QueryClient instance.

How do I handle ERC-20 approvals before a DeFi transaction?

Read the current allowance with useReadContract, compare it to the required amount, and call approve via useWriteContract if insufficient. Wait for confirmation with useWaitForTransactionReceipt, refetch the allowance, then execute the main transaction.