OnchainKit was Coinbase’s React and TypeScript toolkit for building onchain app interfaces. Its repository is archived, and its maintainers say the packages will no longer receive fixes or security updates. For new apps, skip OnchainKit and consider wagmi for React wallet state and viem for Ethereum interactions. For an existing app, this guide shows how to verify RPC access, replace a wallet flow, and check transactions and any hosted features before removing the old dependency.
OnchainKit’s status and the first migration step
The OnchainKit repository is read-only and tells developers not to use its packages in new projects. Existing builds may still run, but a successful install or a working demo is not evidence of ongoing maintenance. The OnchainKit Playground illustrates the kinds of interfaces the toolkit provided, including wallet, transaction, identity, swap, and funding components. Treat it as a reference for what your app may need to replace, not as an installation guide or a guarantee that any underlying service is still available.
If you maintain an existing app, start by finding every @coinbase/onchainkit import and locating the provider setup. Pick one low-risk flow—connect a wallet and read its balance is a good candidate—and reproduce it on a testnet before replacing transaction UI. If your app depends on sponsorship, swaps, or funding, inventory those services now: replacing a React component does not move its backend integration.
Migration prerequisites and feature inventory
Work on a branch with the current lockfile preserved. The examples assume an existing React app, a disposable browser wallet, and an Ethereum JSON-RPC endpoint for Base Sepolia. No private key is needed for the endpoint check. If you later test a write, use a test wallet and a known test contract. Record the expected chain ID, contract address, and ABI per environment rather than assuming that a mainnet deployment also exists on testnet.
Search for more than direct imports. Check shared wrapper components, styles, environment variables, provider configuration, and callbacks that analytics or business logic consume. Record what the user sees on wallet rejection, pending submission, and confirmation. Those details are easy to lose when a single component previously handled the entire flow.
- Wallet and identity: list required connectors, any smart wallet behavior, and the source of names or avatars.
- Transactions: record contract calls, batching requirements, sponsorship policy, and when the app reports success.
- Swap, funding, and checkout: identify the quote or payment service, credentials, and how the app verifies completion.
Wallet state, signing, RPC, and hosted services
OnchainKit combined prebuilt UI with integration logic. In a direct implementation, wagmi can manage React connection state and wallet actions, while viem supplies typed Ethereum clients and operations. A viem public client reads chain data and can simulate contract calls. A wallet client requests signatures and sends transactions through the wallet. The wallet’s transport can differ from the app’s read RPC, so a successful balance lookup does not prove that the wallet can submit on the same chain.
Neither library is a drop-in replacement for the whole toolkit. An injected browser connector does not reproduce a smart wallet onboarding flow. A chain RPC endpoint does not by itself provide transaction sponsorship, swap quotes, or a fiat onramp. Give each of those capabilities an explicit owner in the replacement design. In particular, do not silently turn a previously sponsored action into a user-paid transaction.
Base Sepolia RPC verification
Run these commands with RPC_URL set in your shell. They test chain identity and access to the latest block independently of React and your wallet. Base Sepolia’s chain ID is 84532, returned by eth_chainId as 0x14a34. eth_blockNumber should return a hex-encoded block height; there is no fixed height to match.
: "${RPC_URL:?Set RPC_URL to your Base Sepolia JSON-RPC endpoint}"
for method in eth_chainId eth_blockNumber; do
curl --silent --show-error --fail-with-body --max-time 15 \
-H 'Content-Type: application/json' \
--data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"$method\",\"params\":[]}" \
"$RPC_URL" || break
printf '\n'
doneA minimal wallet and balance replacement
In your migration branch, install a compatible set of dependencies. This example targets the wagmi v2 API: npm install wagmi@2 viem@2 @tanstack/react-query@5. Put the following in App.jsx and render App with rpcUrl set to a browser-safe Base Sepolia endpoint from your app’s configuration. In a framework with server components, run this module on the client. If your app already has wagmi and query providers, reuse them and merge the configuration instead of creating a second provider stack.
This example assumes one injected browser wallet is available. Connect on Base Sepolia and verify that the address matches the wallet and that a balance appears, including a valid zero balance. Switch the wallet to a different chain and verify that the balance is hidden until you switch back. The component does not sign or send transactions. Do not pass a server-only credential as rpcUrl: browser requests and their URLs are visible to users.
'use client';
import { useState } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WagmiProvider, createConfig, http, useAccount, useBalance, useConnect, useDisconnect, useSwitchChain } from 'wagmi';
import { baseSepolia } from 'wagmi/chains';
import { injected } from 'wagmi/connectors';
import { formatEther } from 'viem';
function WalletBalance() {
const { address, chainId, isConnected } = useAccount();
const connect = useConnect();
const disconnect = useDisconnect();
const switchChain = useSwitchChain();
const onTestnet = isConnected && chainId === baseSepolia.id;
const balance = useBalance({ address, chainId: baseSepolia.id, query: { enabled: onTestnet && Boolean(address) } });
const error = connect.error ?? switchChain.error;
return (
<main>
{!isConnected ? connect.connectors.map((connector) => (
<button key={connector.uid} disabled={connect.isPending}
onClick={() => connect.connect({ connector })}>Connect {connector.name}</button>
)) : (
<>
<p>{address}</p>
<button onClick={() => disconnect.disconnect()}>Disconnect</button>
{!onTestnet && <button disabled={switchChain.isPending}
onClick={() => switchChain.switchChain({ chainId: baseSepolia.id })}>Switch to Base Sepolia</button>}
{onTestnet && <p>{balance.isError ? 'Balance read failed' : balance.data ? `${formatEther(balance.data.value)} ETH` : 'Reading balance…'}</p>}
</>
)}
{error && <p role="alert">{error.shortMessage ?? error.message}</p>}
</main>
);
}
export default function App({ rpcUrl }) {
if (!rpcUrl) throw new Error('Provide a browser-safe Base Sepolia RPC URL');
const [config] = useState(() => createConfig({
chains: [baseSepolia],
connectors: [injected()],
transports: { [baseSepolia.id]: http(rpcUrl) },
}));
const [queryClient] = useState(() => new QueryClient());
return <WagmiProvider config={config}>
<QueryClientProvider client={queryClient}><WalletBalance /></QueryClientProvider>
</WagmiProvider>;
}Transaction lifecycle and feature parity
For an ordinary wallet-signed contract write, pass the expected chain, account, contract address, ABI, and arguments into your flow. Simulate the call with viem’s simulateContract, then use its returned request with writeContract on the wallet client. Simulation can catch a revert under the state it observes, but state may change before inclusion. Once you have a transaction hash, wait for the receipt with waitForTransactionReceipt on the public client. Show submitted and confirmed as distinct states, and check the receipt status before reporting success.
On testnet, verify the expected event or resulting contract state as well as the receipt. Exercise rejection, a reverting call, and a receipt wait that times out. A timeout does not prove that a transaction failed; retain the hash and reconcile its status before offering to resubmit. If the old flow used smart accounts, batching, or a paymaster, test those separately. An account-abstraction user operation can return an operation hash rather than a transaction hash, so monitor it through the corresponding user-operation flow before checking the chain receipt.
Troubleshooting by failure boundary
Start at the earliest failing boundary. If the RPC probe fails, changing the React provider is unlikely to help. If it passes but the UI fails, inspect the browser request and the connected wallet’s chain. An HTTP success status is not enough: a JSON-RPC response can contain an error object instead of a result.
- Wrong chain ID: check which environment supplied the transport URL, then check the wallet network separately. Changing one does not change the other.
- Terminal works, browser fails: inspect CORS, endpoint restrictions, and whether the expected configuration reached the client build. Never fix this by exposing a server-only key.
- Connection works, simulation reverts: verify the contract deployment, ABI, sender, arguments, and required value. A contract revert is not necessarily an RPC fault.
- Transaction hash exists, UI remains pending: check that the receipt client is polling the submission chain, then reconcile the original hash before enabling another send.
- Only sponsored actions fail: check the sponsor’s chain configuration and policy eligibility separately from whether the public RPC can read blocks.
Reproducible migration checks
Run the legacy and replacement flows under the same browser, wallet, chain, and network conditions. Use the same RPC configuration where both builds allow it; if they do not, record that difference rather than attributing all timing changes to the UI. Set a sample count and timeout in advance, separate cold from warm loads, and record errors and timeouts alongside successes. Measure wallet approval time separately from RPC request time so human response time does not distort your diagnosis.
| Check | Measurement | Legacy build | Replacement build |
|---|---|---|---|
| Wallet connection | Successful connections / attempts, with errors grouped by type | Record | Record |
| Balance read | Request-to-response p50 and p95 for successful reads; timeouts / attempts separately | Record | Record |
| Transaction confirmation | Hash-to-successful-receipt time; confirmed, reverted, and unresolved counts | Record | Record |
| Sponsored transaction, if required | Eligible attempts sponsored as expected; unexpected user-paid prompts | Record | Record |
Use browser network timings or app instrumentation for reads and a monotonic timer for lifecycle intervals. Record the sample count beside each percentile; with a small sample, keep the individual observations instead of relying on a noisy p95. Keep manual rejection tests separate from unexpected failures.
Rollout decisions and infrastructure next steps
Direct wagmi and viem integration gives you control over UI states and RPC configuration, but your team takes responsibility for connector UX, accessibility, and transaction recovery. A maintained prebuilt wallet UI may reduce that work if it supports the connectors and chains you need. Evaluate specialized services separately for feature parity. Roll out behind a feature flag, define rollback criteria, and remove the old package, styles, and unused credentials once no route depends on them.
For the RPC portion of the rollout, check the network directory for the exact chain and environment you intend to use, then review RPC API service options and RPC pricing and plan limits against your measured call volume. Consider dedicated node infrastructure if you have an isolation or capacity requirement that warrants evaluating it. Use the OnFinality Learn library for further integration and troubleshooting workflows.