transfer(to, value) call on the USDC contract. The JS SDK exposes a viem WalletClient for any wallet account via createWalletClientForWalletAccount — you read the account from getWalletAccounts (or useGetWalletAccounts in React), encode the call with viem’s erc20Abi, and you’re done.
Setup
Follow the JavaScript Quickstart for a vanilla setup, or the React Quickstart (JS SDK) for a Vite + React app with<DynamicProvider> and the EVM extension. The rest of this guide picks up from there.
Install viem alongside the SDK packages:
Step 1: Get the USDC contract address
USDC is deployed at a different address on every chain. Look up the right one on Circle’s references: USDC has 6 decimals on every EVM chain — always convert withparseUnits(amount, 6).
Step 2: Build the send function
Read the user’s EVM wallet account withgetWalletAccounts (or useGetWalletAccounts in React), narrow it with isEvmWalletAccount, then call writeContract against the USDC contract using viem’s built-in erc20Abi.
- JavaScript
- React
createWalletClientForWalletAccount signs on whatever network the wallet is currently on. To target a specific chain, switch the wallet first with switchActiveNetwork — useSwitchActiveNetwork in React.Handling errors
Wrap the send call (sendUsdc in the JavaScript tab, handleSend in the React tab) in a try/catch and match on the message to tell the common failures apart:
simulateEvmTransaction, which returns the expected asset changes plus a security verdict.
Related
createWalletClientForWalletAccount— viem wallet client for any EVM wallet accountcreatePublicClientFromNetworkData— viem public client for reads and receiptsisEvmWalletAccount— type guard for EVM accounts- Sign and send a transaction — lower-level transaction reference
getTokenBalances— check the sender’s USDC balance before transferring- EVM gas sponsorship — pay the user’s gas for them
simulateEvmTransaction— preview a transfer before sending- Receiving USDC
- Sending USDC by email or phone