Skip to main content
USDC is a digital dollar issued by Circle, also known as a stablecoin, designed to represent US dollars on the internet and operate seamlessly across many of the world’s leading blockchains, including World Chain. Backed 100% by highly liquid cash and cash-equivalent assets, USDC is always redeemable 1:1 for USD. Circle provides monthly attestation reports for USDC reserve holdings on its Transparency page. On World Chain, USDC can be transferred using its token contract, enabling fast, secure, and programmable digital dollar transactions. This guide will walk you through building a simple script to perform your first USDC transaction on World Chain.

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn

Part 1: Setup up your project

Step 1: Create a new project directory:

Step 2: Enable ES module support:

In your package.json, add the following line:
This allows you to use the modern ES module syntax (import/export) in your script. Tip: Alternatively, you can use the following command to set "type": "module" directly:

Step 3: Install required dependencies:

Step 4: Create your script file:

Create a new file called index.js:

Part 2: Build the script

Open index.js and complete the following sections:

Step 1: Import Dependencies

These imports include:
  • viem for blockchain interactions
  • @inquirer/prompts for interactive CLI prompts
  • fs and path for saving private key backups

Step 2: Define Constants

  • USDC_CONTRACT is the address of the USDC token on World Chain Sepolia
  • USDC_DECIMALS is the number of decimals used in USDC calculations
The above ABI defines the minimum required functions for:
  • Transferring USDC
  • Checking USDC balance
  • Getting USDC decimals

Step 3: Add Helper Functions

These functions:
  • Generate new wallets
  • Save them as JSON files for backup

Step 4: Add Main Function

This function drives the full flow to:
  • Create wallets
  • Back up credentials
  • Prompt you to fund the source wallet
  • Send USDC to the destination
  • Print the transaction hash

Part 3: Run the Script

Enter the following command:
Follow the prompts in your terminal.

What This Script Does

  1. Creates source and destination wallets
  2. Saves wallet information securely
  3. Prompts you to fund the source wallet
  4. Transfers USDC between wallets
  5. Displays the transaction hash and link to the explorer

Important Notes

  • Keep your private keys secure
  • Delete backup files after use
  • Always test with small amounts first
  • This script uses World Chain Sepolia testnet, not mainnet