A beginner-friendly TypeScript application for sending USDC between EVM-compatible wallets using Circle's USDC contracts and the Viem library.
This project demonstrates how to securely transfer USDC across supported EVM testnets while teaching the fundamentals of blockchain transactions, wallet management, and ERC-20 token interactions.
This project allows you to:
- Load wallet credentials securely using environment variables.
- Connect to multiple supported EVM testnets.
- Check your USDC balance before sending.
- Transfer USDC to another wallet.
- Wait for transaction confirmation.
- View the transaction on the appropriate blockchain explorer.
Whether you're a beginner exploring blockchain development or an experienced developer looking for a simple USDC transfer example, this repository provides a solid foundation.
transfer-usdc-evm/
│
├── node_modules/
├── .env
├── .gitignore
├── index.ts
├── package.json
├── package-lock.json
└── tsconfig.json
Before running this project, ensure you have the following installed:
- Node.js (v20 or later recommended)
- npm
- Visual Studio Code (recommended)
- Git (optional)
- A wallet containing testnet USDC
- Testnet gas tokens for the selected network
Verify your installation:
node -v
npm -vmkdir transfer-usdc-evm
cd transfer-usdc-evmmkdir transfer-usdc-evm
cd transfer-usdc-evmnpm init -yInstall runtime dependencies:
npm install viem dotenvInstall development dependencies:
npm install -D typescript tsx @types/nodenpx tsc --initCreate the following files:
.env
index.ts
.gitignore
New-Item .env -ItemType File
New-Item index.ts -ItemType File
New-Item .gitignore -ItemType FileReplace your package.json with:
{
"name": "transfer-usdc-evm",
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "tsx index.ts"
},
"dependencies": {
"dotenv": "^17.0.0",
"viem": "^2.53.1"
},
"devDependencies": {
"@types/node": "^26.0.1",
"tsx": "^4.22.4",
"typescript": "^6.0.3"
}
}Install packages:
npm installCreate a .env file in the project root.
PRIVATE_KEY=0xYOUR_PRIVATE_KEY
RECIPIENT_ADDRESS=0xYOUR_RECIPIENT_ADDRESSYour private key must:
- Begin with
0x - Contain exactly 64 hexadecimal characters after
0x - Never be shared publicly
- Never be committed to GitHub
Create a .gitignore file:
node_modules
.envThis prevents sensitive files from being uploaded to GitHub.
Start the application:
npm startYou will see a list of supported testnets:
Select a chain for your USDC transfer:
1. Arc Testnet
2. Arbitrum Sepolia
3. Avalanche Fuji
...
Enter the corresponding number for your desired network.
Example:
Enter a number: 1
The application will then:
- Connect to the selected blockchain.
- Load your wallet.
- Display your USDC balance.
- Transfer USDC to the recipient.
- Wait for transaction confirmation.
- Display the transaction hash.
- Provide a blockchain explorer URL.
Example output:
Sender: 0x...
Recipient: 0x...
Balance: 160.67131 USDC
Transaction submitted.
Tx Hash:
0x...
Transfer confirmed!
The application follows these steps:
- Loads environment variables from
.env. - Validates the private key and recipient address.
- Converts the private key into a wallet account.
- Connects to the selected blockchain.
- Reads the sender's USDC balance.
- Executes an ERC-20
transfer()transaction. - Waits until the transaction is confirmed.
- Displays the transaction details.
Used to read blockchain data.
Examples:
- Wallet balances
- Block numbers
- Smart contract state
Used to sign and send blockchain transactions.
Examples:
- Sending USDC
- Approving ERC-20 tokens
- Calling smart contract functions
Converts your private key into an account that can sign blockchain transactions.
Reads the sender's USDC balance from the USDC smart contract.
Transfers USDC from the sender wallet to the recipient wallet.
Ensure package.json contains:
"scripts": {
"start": "tsx index.ts"
}Windows PowerShell does not support touch.
Use:
New-Item index.ts -ItemType FileEnsure your private key:
- Starts with
0x - Has exactly 66 characters (including
0x) - Is your private key, not your wallet address or recovery phrase
Solution:
- Install
dotenv - Ensure
import "dotenv/config";is the first line inindex.ts - Verify
.envis located in the project root
Install dotenv:
npm install dotenv- Never expose your private key.
- Never upload
.envto GitHub. - Always test on testnets before using mainnet.
- Use separate wallets for development and production.
- Rotate your private key immediately if it is accidentally exposed.
You can extend this project by adding:
- Custom transfer amounts entered at runtime.
- A React or Next.js frontend.
- WalletConnect integration.
- Support for multiple recipients.
- Transaction history.
- Balance caching.
- Mainnet support.
- Circle API integration.
- QR code scanning for recipient addresses.
- Circle Developer Documentation
- Viem Documentation
- TypeScript Documentation
- Ethereum ERC-20 Token Standard
Contributions are welcome.
If you'd like to improve this project:
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Open a Pull Request.
This project is provided for educational purposes.
Feel free to modify, reuse, and extend it for your own applications.
This project is inspired by the official Circle Developer Quickstart for transferring USDC on EVM-compatible networks and demonstrates how to interact with ERC-20 USDC contracts using the Viem library in a clean, beginner-friendly TypeScript application.