One command migrates your wagmi v1 codebase to v2. Deterministic AST transforms with zero false positives.
Tested on scaffold-eth-2 with 100% safety.
What it does
Automatically migrates the most common wagmi v1 → v2 patterns:
Pattern
Migration
useContractRead
→ useReadContract
useContractWrite
→ useWriteContract
usePrepareContractWrite
→ useSimulateContract
useWaitForTransaction
→ useWaitForTransactionReceipt
useSwitchNetwork
→ useSwitchChain
WagmiConfig
→ WagmiProvider
createClient (from wagmi only)
→ createConfig
configureChains()
Flagged with TODO
onSuccess/onError callbacks
Flagged with TODO
autoConnect config
Flagged with TODO
watch: true
Flagged with TODO
What needs manual follow-up
Connector API rewrites: InjectedConnector() → injected(), etc.
Custom useBalance() token param removals
Transport configuration setup
TanStack Query v5 migration patterns
Installation
bash
npm install -D codemod
# or
bunx codemod@latest add wagmi-v1-to-v2
Usage
bash
# Run locally in current project
npx codemod workflow run -w node_modules/@your-org/wagmi-v1-to-v2
# Or with npx from registry (when published)
npx codemod @your-org/wagmi-v1-to-v2 --target ./src