©️CCTP

Cross-Chain Transfer Protocol (CCTP) Explanation

This backend implementation demonstrates the process of burning USDC on the Ethereum network (via Arbitrum) to initiate a cross-chain transfer to Noble using Circle's Cross-Chain Transfer Protocol (CCTP). The code performs key tasks including contract initialization, token approval, burning, and attestation validation. Here's a detailed breakdown:

1. Burn USDC on Ethereum

a. Initialize Contracts

Contracts are initialized using their respective ABIs and addresses:

  • USDC Contract: Allows approval for token transfers.

  • Token Messenger Contract: Facilitates the cross-chain burn process.

b. Approve Tokens for Burn

Before burning, the USDC contract requires approval for the TokenMessenger to withdraw tokens from the user's address.

  • usdcEthContract.methods.approve is called with the token messenger contract address and the amount to be burned.

c. Deposit for Burn

The actual burning process is done using the depositForBurn method of the TokenMessenger contract.

  • Parameters include the amount, destination chain ID (4 for Noble), recipient address in bytes, and the USDC contract address.


2. Retrieve Message and Generate Attestation

a. Extract Message Bytes

After burning, the transaction logs contain a MessageSent event. This log contains the messageBytes required for attestation.

  • The message is decoded and hashed (messageHash) to fetch its attestation status from Circle’s API.

b. Fetch Attestation

The attestation is periodically polled using Circle's iris-api-sandbox.

  • When the attestation is complete, it signifies that the burn transaction has been acknowledged by Circle.


3. Send to Noble

Using the ethToNoble function:

  • The attestation (attestation) and the message (messageBytes) are passed to the Noble-specific contract.

  • This part would typically involve calling the Noble chain's specific contract to "mint" the USDC equivalent from the burn transaction on Ethereum.


Problems Addressed

  1. Cross-Chain Compatibility: CCTP simplifies interoperability between EVM and Cosmos ecosystems.

  2. Secure Token Movement: Using Circle's attestation mechanism ensures that tokens are securely burned and minted across chains.

  3. User Experience: The automation of polling and attestation makes the process seamless for users, abstracting away complex cross-chain operations.

Last updated