Base official migrating an onchainkit app

From jiayaoqijia/cryptoskill · View interactive version

Base official migrating an onchainkit app is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Migrates apps from @coinbase/onchainkit to standalone wagmi/viem components. Handles provider replacement (OnchainKitProvider to WagmiProvider), wallet component replacement (Wallet/ConnectWallet to custom WalletConnect), and transaction component replacement. Use when the user says "migrate my onch

How to use this skill

Skill file

OnchainKit Migration Skill

Migrate apps from @coinbase/onchainkit to standalone wagmi/viem components with zero OnchainKit dependency.

Before Starting

Create a mistakes.md file in the project root:

# Migration Mistakes & Learnings

Track errors, fixes, and lessons learned during OnchainKit migration.

## Errors

## Lessons Learned

Append every error, fix, and lesson to this file throughout the migration. This file improves the skill over time.

Migration Workflow

Migrations MUST happen in this order. Do not skip steps.

Step 1: Detection

Scan the project to understand current OnchainKit usage:

  1. Search all files for @coinbase/onchainkit imports
  2. Identify which components are used:
  1. Check package.json for existing wagmi, viem, @tanstack/react-query dependencies
  2. Identify the project's styling approach (Tailwind, CSS Modules, styled-components, etc.)
  3. Report findings to the user before proceeding

Step 2: Provider Migration (always first)

Read references/provider-migration.md for detailed instructions and code.

Summary:

  1. Ensure wagmi, viem, and @tanstack/react-query are installed
  2. Create wagmi-config.ts with chain and connector configuration
  3. Replace OnchainKitProvider with WagmiProvider + QueryClientProvider
  4. Remove @coinbase/onchainkit/styles.css import
  5. Remove any SafeArea or MiniKit imports from layout files

Validation gate: Run npm run build (or the project's build command). Must pass before continuing. If it fails, fix errors and document them in mistakes.md.

Step 3: Wallet Migration (after provider)

Read references/wallet-migration.md for detailed instructions and code.

Summary:

  1. Create a WalletConnect component using wagmi hooks (useAccount, useConnect, useDisconnect)
  2. Component includes a modal with wallet options: Base Account, Coinbase Wallet, MetaMask
  3. Shows truncated address + disconnect button when connected
  4. Replace all OnchainKit wallet imports and component usage

Validation gate: Run npm run build. Must pass before continuing. Document any errors in mistakes.md.

Step 4: Transaction Migration (after wallet)

Read references/transaction-migration.md for detailed instructions and code.

Summary:

  1. Check the chainId prop on existing <Transaction /> components -- add any missing chains to wagmi-config.ts
  2. Create a TransactionForm component using wagmi hooks (useWriteContract, useWaitForTransactionReceipt, useSwitchChain)
  3. Component handles the full lifecycle: idle, pending wallet confirmation, confirming on-chain, success, error
  4. Replace all OnchainKit transaction imports (Transaction, TransactionButton, TransactionStatus, TransactionSponsor, etc.)
  5. Update the calls array format -- use address, abi, functionName, args with proper as const typing
  6. Map onStatus callback to the new lifecycle status names (init, pending, confirmed, success, error)

Validation gate: Run npm run build. Must pass before continuing. Document any errors in mistakes.md.

Step 5: Cleanup

  1. Search for any remaining @coinbase/onchainkit imports -- there should be none
  2. Optionally remove @coinbase/onchainkit from package.json dependencies
  3. Run final npm run build to verify everything works
  4. Update mistakes.md with final lessons learned

Troubleshooting

Build fails after provider migration

MetaMask SDK react-native warning

Wallet won't connect

Transaction receipt stuck in pending

Transaction targets wrong chain

Next.js page export restrictions

ABI type errors after transaction migration

Existing wagmi setup detected

Important Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.