Skip to main content
USDC on Aptos is a fungible asset issued by Circle. Transferring USDC between Aptos accounts moves the asset between primary fungible stores. The @aptos-labs/ts-sdk script you build in this guide will:
  • Load your sender wallet from a private key
  • Check your testnet USDC balance
  • Transfer USDC to a recipient address you set in the script

Prerequisites

Before you begin, ensure that you’ve:
  • Installed Node.js v22.6+
  • Set up a terminal and code editor for running commands and editing files
  • Created an Aptos Testnet wallet with the private key available

Contract addresses

You need the following Aptos Testnet USDC fungible asset metadata address:

Step 1: Set up the project

1.1. Create the project and install dependencies

Create a new directory, setup a Node.js project, and install the required dependencies:
Shell

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. Configure environment variables

Create a .env file in your project directory and add your sender’s private key. Use either an AIP-80 formatted key (ed25519-priv-0x...) or a raw hex private key from your wallet export.
.env
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.
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

Add main.ts at the project root. The script:
  1. Loads your existing sender wallet from the environment variable
  2. Reads the sender’s USDC balance
  3. Builds a fungible asset transfer to your recipient address
  4. Signs, submits, and waits for the transaction
Replace 0xYOUR_RECIPIENT_ADDRESS with the Aptos address that should receive the USDC.
main.ts

Step 3: Run the script

From the project directory, run:
Shell
Your output should look similar to the following (addresses and hashes will differ):
Shell
Open the explorer URL from the Transfer confirmed: line to view the transaction on Aptos Testnet.
Common errors you might encounter:
  • Set APTOS_PRIVATE_KEY in .env: The private key is missing. Add APTOS_PRIVATE_KEY to .env and run with npm run start (which loads the file via --env-file).
  • Insufficient USDC: The sender does not have enough testnet USDC. Fund the wallet from the Circle Faucet before running the script.
  • Transaction failure / out of gas: The sender needs testnet APT for fees. Request APT from the Aptos Faucet.