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 yourpackage.json
, add the following line:
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 calledindex.js
:
Part 2: Build the script
Openindex.js
and complete the following sections:
Step 1: Import Dependencies
viem
for blockchain interactions@inquirer/prompts
for interactive CLI promptsfs
andpath
for saving private key backups
Step 2: Define Constants
USDC_CONTRACT
is the address of the USDC token on World Chain SepoliaUSDC_DECIMALS
is the number of decimals used in USDC calculations
- Transferring USDC
- Checking USDC balance
- Getting USDC decimals
Step 3: Add Helper Functions
- Generate new wallets
- Save them as JSON files for backup
Step 4: Add Main Function
- 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:What This Script Does
- Creates source and destination wallets
- Saves wallet information securely
- Prompts you to fund the source wallet
- Transfers USDC between wallets
- 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