Send USDC (or other ERC-20s)
In this recipe you’ll construct an ERC-20 transfer
call and submit it through a Smart Account Client. The same pattern works for any ERC-20 token; just swap the token address and number of decimals.
Prefer code? Jump straight to the React or Core tabs below.
Prerequisites
- Account Kit integrated in your app (see the React quickstart or Core quickstart).
- A connected user with an on-chain smart account.
- The USDC contract address for your target chain. For Ethereum mainnet this is
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
.
- Visit Circle’s documentation for USDC addresses on other chains.
1. Encode the transfer
calldata
2. Send the transaction
React (hook)
Core (vanilla JS)
3. Wait for the transaction to be mined
If you’re using the React hooks with waitForTxn: true
, the transaction will automatically be waited for. You can access the transaction hash from sendUserOperationResult
:
Alternatively, you can manually wait for the transaction:
Next steps
- Parameterize the token address/decimals to support any ERC-20.
- Batch multiple user operations in one request (e.g. aprrove, transfer, etc).
- Combine with sponsored gas for a completely gas-less UX.