Welcome to this session on Cross-Chain Transfer Protocol (CCTP). In this video, we’ll walk through how to set up and execute cross-chain USDC transfers using smart contracts and JavaScript. You’ll learn the full workflow from project setup to minting on the destination chain.
We begin with an existing developer-controlled wallet project and switch to a new branch named cctp. The idea is to reuse the existing structure and add new CCTP functionalities.
To get started, you'll need an RPC provider. For this example, we’re using Infura, but you can also use alternatives like Alchemy. After signing into Infura, retrieve your API key and paste it into the appropriate location in cctp-functions.js.
Check the .env file—it contains essential variables:
These variables are critical for transaction execution. In production, this data should be dynamically managed through function returns, rather than hardcoded.
In the helper functions under createWallet, ensure you configure wallets for both Ethereum Sepolia and Polygon Mumbai testnets. You need wallets on both chains to perform cross-chain transfers.
Run npm run start after ensuring all dependencies are installed with npm install. This step interacts with the smart contract to approve burning USDC.
Once approved, execute the burnUSDC function. This will burn the token on the Ethereum chain. After successful execution, note the burnTransactionId.
Use the burnTransactionId to get attestation data. This step waits for the burn transaction to be confirmed on-chain. Once confirmed, you’ll receive:
These are needed to mint USDC on the destination chain.
Run the mintUSDC function, passing:
Once complete, the receiver wallet (e.g., on Polygon Mumbai) will reflect the newly minted USDC.
The key functions include:
All functions use Web3.js for interacting with contracts and encoding data. cipherText is regenerated in each step for enhanced security.
After executing all steps, you’ll see the final balance updated in the destination wallet. For example, if the wallet initially had 11 USDC and 1 USDC was transferred, the final balance should show 12 USDC.
This process demonstrates how to use CCTP for secure, verifiable cross-chain USDC transfers. While we manually passed variables for clarity, in real-world applications, these would be handled dynamically by your code.
Swap insights and ask questions about “Learn everything about Circle and USDC”.
Ask a question or share your thoughts about this lesson.