Skip to main content
Send 1 USDC to a recipient address on a supported EVM testnet using Viem and Node.js. No Circle account required.

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)

This step is optional. It helps prevent missing types in your IDE or editor.
Create a tsconfig.json file:
Then, update the 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.
Open .env in your editor rather than writing values with shell commands, and add .env to your .gitignore. This prevents credentials from leaking into your shell history or version control.
The npm run start command loads variables from .env using Node.js native env-file support.
This example uses one or more private keys for local testing. In production, use a secure key management solution and never expose or share private keys.

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

In index.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

If you see an ExperimentalWarning about type stripping, you can safely ignore it. You’ll see output similar to the following:
To verify the transfer, open the URL from the Explorer: line in your browser. This takes you to the testnet’s block explorer, where you can view full transaction details.

Next steps