1. Get the USDC contract address
To send USDC, you’ll need the contract address for USDC. The address is different for each network, so make sure you get the correct address for the network you’re targeting. You can go to Circle’s website to look up the USDC address on both main networks and test networks.2. Format the transaction send input data
USDC, and other ERC-20 tokens, are smart contracts. In order to send these tokens, your transaction needs to call thetransfer
function on the contract, which takes in two parameters:
to
: The address of the recipientvalue
: The amount of tokens to send
viem
to provide the ABI and encode the function parameters.
Additionally, each ERC-20 token defines a decimals
value, which is the number of decimal places for the token. For USDC, the decimals
value is usually 6, but for most other ERC-20 tokens, it’s 18.
- Typescript
- Python
First, install the Then, build the transaction input data.
viem
package if it is not installed yet.3. Send the transaction
You can send the transaction using the Privy API. Below are examples for React, React Native, and NodeJS; you can find other SDKs’ send transaction examples in the Send a transaction guide.- React
- React Native
- NodeJS
- NodeJS (server-auth)
- Python