Rise In Logo

Learn everything about Circle and USDC

CCTP

CCTP

Introduction to Cross-Chain Transfers with CCTP

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.

Setting Up the Project and Dependencies

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.

Project Files and Configuration

Check the .env file—it contains essential variables:

  • sender_wallet_id
  • sender_address
  • receiver_wallet_id
  • receiver_address
  • Smart contract addresses (Token Messenger and Message Transmitter)

These variables are critical for transaction execution. In production, this data should be dynamically managed through function returns, rather than hardcoded.

Wallets Setup

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.

Step-by-Step CCTP Process

1. Approve USDC for Burning

Run npm run start after ensuring all dependencies are installed with npm install. This step interacts with the smart contract to approve burning USDC.

2. Burn USDC on the Source Chain

Once approved, execute the burnUSDC function. This will burn the token on the Ethereum chain. After successful execution, note the burnTransactionId.

3. Fetch Attestation and Message Bytes

Use the burnTransactionId to get attestation data. This step waits for the burn transaction to be confirmed on-chain. Once confirmed, you’ll receive:

  • Message bytes
  • Attestation code

These are needed to mint USDC on the destination chain.

4. Mint USDC on the Destination Chain

Run the mintUSDC function, passing:

  • message_bytes
  • attestation
  • receiver_wallet_id
  • Destination chain’s message_transmitter_contract_address

Once complete, the receiver wallet (e.g., on Polygon Mumbai) will reflect the newly minted USDC.

Exploring the Core Functions

The key functions include:

approveUSDC

  • Uses a POST request with your API key and wallet ID.
  • Sends a transaction to approve the USDC for burning.

burnUSDC

  • Encodes the destination address.
  • Sends the burn request to the tokenMessenger contract.

fetchDepositTransaction & getAttestation

  • Retrieves transaction details and the necessary attestation using the burn transaction ID.

mintUSDC

  • Sends the final mint transaction using the messageTransmitter contract on the destination chain.
  • Uses message_bytes, attestation, and the receiver_wallet_id.

All functions use Web3.js for interacting with contracts and encoding data. cipherText is regenerated in each step for enhanced security.

Final Output

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.

Summary

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.

Comments

You need to enroll in the course to be able to comment!

Stay in the know

Never miss updates on new programs and opportunities.

Rise In Logo

Rise together in web3!

Disclaimer: The information /programs / events provided on https://patika.dev and https://risein.com are strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice and do not make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://patika.dev and https://risein.com disclaim any responsibility for financial decisions made by users based on information provided here.