Prerequisites
Before you begin, ensure that you’ve:- Installed Node.js v22.6+
- Created two EVM testnet wallet addresses: one to send from and one to receive
- Funded the source wallet with testnet USDC from the Circle Faucet
- Funded the source wallet with testnet native tokens for gas fees (such as ETH on Ethereum Sepolia)
Step 1. Set up the project
1.1. Create the project and install dependencies
Create a new directory and install the required dependencies:1.2. Configure TypeScript (optional)
Create atsconfig.json file:
tsconfig.json file:
1.3. Set environment variables
Create a.env file in the project directory. Replace {YOUR_PRIVATE_KEY} with
the private key from your sending wallet and {YOUR_RECIPIENT_ADDRESS} with the
address you want to receive the USDC.
If you use MetaMask, follow their guide for how to find and export your
private
key.
PRIVATE_KEY: the private key for the EVM wallet sending the transfer.RECIPIENT_ADDRESS: the EVM wallet address that will receive the USDC.
npm run start command loads variables from .env using Node.js native
env-file support.
Step 2. Create the transfer script
The script derives supported chains from Viem, prompts you to choose one at runtime, and then runs the same transfer flow for that chain.2.1. Create the script file
2.2. Add the script
Inindex.ts, add the following script. It derives supported chains from the
USDC token definition and chain definitions in Viem, so the transfer flow stays
shared across EVM testnets. The script uses the client-attached ERC-20 token
actions and the USDC token definition from viem/tokens.
TypeScript
Step 3. Run the script
ExperimentalWarning about type stripping, you can safely ignore
it.
You’ll see output similar to the following:
Explorer: line in your browser.
This takes you to the testnet’s block explorer, where you can view full
transaction details.
Next steps
- Set up developer-controlled wallets: Create and manage wallets programmatically for multi-user applications.
- Sponsor gas fees: Use Gas Station so your users don’t need to hold tokens for gas.
- Bridge USDC across blockchains: Move USDC between blockchains using CCTP.
- Transfer EURC on EVM: Transfer EURC on EVM blockchains using the same approach.