Prerequisites
Before you begin, ensure that you’ve:- Installed Node.js v22+
- Prepared an EVM testnet wallet with the private key available
- Added Arc testnet network to your wallet (network details)
- Funded your wallet with the following testnet tokens:
- Sepolia ETH (native token) from a public faucet
- Sepolia USDC from the Circle Faucet
- Arc testnet USDC (for gas fees) from the Circle Faucet
Step 1. Set up the project
This step shows you how to prepare your project and environment.1.1. Set up your development environment
Create a new directory and install the required dependencies:Shell
1.2. Initialize and configure the project
This command creates atsconfig.json file:
Shell
tsconfig.json file:
Shell
1.3. Configure environment variables
Create a.env file in the project directory and add your wallet private key,
replacing {YOUR_PRIVATE_KEY} with the private key from your EVM wallet.
Shell
Step 2: Configure the script
This section covers the necessary setup for the transfer script, including defining keys and addresses, and configuring the wallet client for interacting with the source and destination chains.2.1. Define configuration constants
The script predefines the contract addresses, transfer amount, and maximum fee. Update theDESTINATION_ADDRESS with your wallet address.
TypeScript
2.2. Set up wallet clients
The wallet client configures the appropriate network settings usingviem. In
this example, the script connects to Ethereum Sepolia and Arc testnet.
TypeScript
Step 3: Implement the transfer logic
The following sections outline the core transfer logic.3.1. Approve USDC
Grant approval for theTokenMessengerV2 contract deployed on
Ethereum Sepolia to withdraw USDC from your wallet. This allows the contract to
burn USDC when you initiate the transfer.
TypeScript
3.2. Burn USDC
Call thedepositForBurn function from the
TokenMessengerV2 contract
deployed on Ethereum Sepolia to burn USDC on that source chain. You specify the
following parameters:
- Burn amount: The amount of USDC to burn
- Destination domain: The target blockchain for minting USDC (see supported chains and domains)
- Mint recipient: The wallet address that will receive the minted USDC
- Burn token: The contract address of the USDC token being burned on the source chain
- Destination caller: The address on the target chain to call
receiveMessage - Max fee: The maximum fee allowed for the transfer
- Finality threshold: Determines whether it’s a Fast Transfer (1000 or less) or a Standard Transfer (2000 or more)
TypeScript
3.3. Retrieve attestation
Retrieve the attestation required to complete the CCTP transfer by calling Circle’s attestation API.- Call Circle’s
GET /v2/messagesAPI endpoint to retrieve the attestation. - Pass the
srcDomainargument from the CCTP domain for your source chain. - Pass
transactionHashfrom the value returned bysendTransactionwithin theburnUSDCfunction above.
TypeScript
3.4. Mint USDC
Call thereceiveMessage function
from the MessageTransmitterV2 contract
deployed on the Arc testnet to mint USDC on that destination chain.
- Pass the signed attestation and the message data as parameters.
- The function processes the attestation and mints USDC to the specified Arc testnet wallet address.
TypeScript
Step 4: Complete script
Create aindex.ts file in your project directory and populate it with the
complete code below.
index.ts
Step 5: Test the script
Run the following command to execute the script:Shell
Rate limit:The attestation service rate limit is 35 requests per second. If you exceed this
limit, the service blocks all API requests for the next 5 minutes and returns an
HTTP 429 (Too Many Requests) response.