Crate cctp_rs

Source
Expand description

§cctp-rs

A production-ready Rust SDK for Circle’s Cross-Chain Transfer Protocol (CCTP).

This library provides a safe, ergonomic interface for bridging USDC across multiple blockchain networks using Circle’s CCTP infrastructure.

§Quick Start

use cctp_rs::{Cctp, CctpError};
use alloy_chains::NamedChain;
use alloy_primitives::FixedBytes;

// Set up providers and create bridge
let eth_provider = ProviderBuilder::new().connect("http://localhost:8545").await?;
let arb_provider = ProviderBuilder::new().connect("http://localhost:8546").await?;

let bridge = Cctp::builder()
    .source_chain(NamedChain::Mainnet)
    .destination_chain(NamedChain::Arbitrum)
    .source_provider(eth_provider)
    .destination_provider(arb_provider)
    .recipient("0x742d35Cc6634C0532925a3b844Bc9e7595f8fA0d".parse()?)
    .build();

// Get attestation for a bridge transaction
let message_hash: FixedBytes<32> = [0u8; 32].into();
let attestation = bridge.get_attestation_with_retry(message_hash, None, None).await?;

§Features

  • Type-safe contract interactions using Alloy
  • Multi-chain support for mainnet and testnet networks
  • Comprehensive error handling with detailed error types
  • Builder pattern for intuitive API usage
  • Extensive test coverage ensuring reliability

§Modules

  • [attestation] - Types for Circle’s Iris API attestation responses
  • [bridge] - Core CCTP bridge implementation
  • [chain] - Chain-specific configurations and the CctpV1 trait
  • [error] - Error types and result type alias
  • [domain_id] - CCTP domain ID constants for supported chains
  • [message_transmitter] - MessageTransmitter contract bindings
  • [token_messenger] - TokenMessenger contract bindings

Modules§

MessageTransmitter
Generated by the following Solidity interface…
TokenMessenger
Generated by the following Solidity interface…

Structs§

AttestationResponse
Represents the response from the attestation service
BridgeParams
Parameters for bridging USDC
BridgeParamsBuilder
Use builder syntax to set the inputs and finish with build().
Cctp
CCTP v1 bridge implementation
CctpBuilder
Use builder syntax to set the inputs and finish with build().
TokenMessengerContract
The CCTP v1 Token Messenger contract.

Enums§

AttestationStatus
Represents the status of the attestation.
CctpError

Constants§

ARBITRUM_DOMAIN_ID
ARBITRUM_MESSAGE_TRANSMITTER_ADDRESS
https://arbiscan.io/address/0xC30362313FBBA5cf9163F0bb16a0e01f01A896ca
ARBITRUM_SEPOLIA_MESSAGE_TRANSMITTER_ADDRESS
https://sepolia.arbiscan.io/address/0xacf1ceef35caac005e15888ddb8a3515c41b4872
ARBITRUM_SEPOLIA_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
ARBITRUM_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
AVALANCHE_DOMAIN_ID
AVALANCHE_MESSAGE_TRANSMITTER_ADDRESS
https://snowtrace.io/address/0x8186359af5f57fbb40c6b14a588d2a59c0c29880
AVALANCHE_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
BASE_DOMAIN_ID
BASE_MESSAGE_TRANSMITTER_ADDRESS
https://basescan.org/address/0xAD09780d193884d503182aD4588450C416D6F9D4
BASE_SEPOLIA_MESSAGE_TRANSMITTER_ADDRESS
https://base-sepolia.blockscout.com/address/0x7865fAfC2db2093669d92c0F33AeEF291086BEFD
BASE_SEPOLIA_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
BASE_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
CHAIN_CONFIRMATION_CONFIG
DEFAULT_CONFIRMATION_TIMEOUT
Default confirmation requirements and timeouts for different chains
ETHEREUM_DOMAIN_ID
ETHEREUM_MESSAGE_TRANSMITTER_ADDRESS
https://etherscan.io/address/0x0a992d191DEeC32aFe36203Ad87D7d289a738F81
ETHEREUM_SEPOLIA_MESSAGE_TRANSMITTER_ADDRESS
https://sepolia.etherscan.io/address/0x7865fAfC2db2093669d92c0F33AeEF291086BEFD
ETHEREUM_SEPOLIA_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
ETHEREUM_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
IRIS_API
Circle Iris API environment URLs
IRIS_API_SANDBOX
OPTIMISM_DOMAIN_ID
OPTIMISM_MESSAGE_TRANSMITTER_ADDRESS
https://optimistic.etherscan.io/address/0x4D41f22c5a0e5c74090899E5a8Fb597a8842b3e8
OPTIMISM_TOKEN_MESSENGER_ADDRESS
https://developers.circle.com/stablecoins/evm-smart-contracts
POLYGON_CCTP_V1_MESSAGE_TRANSMITTER
https://polygonscan.com/address/0x9daF8c91AEFAE50b9c0E69629D3F6Ca40cA3B3FE
POLYGON_CCTP_V1_TOKEN_MESSENGER
https://developers.circle.com/stablecoins/evm-smart-contracts
POLYGON_DOMAIN_ID
UNICHAIN_CCTP_V1_MESSAGE_TRANSMITTER
https://uniscan.xyz/address/0x353bE9E2E38AB1D19104534e4edC21c643Df86f4
UNICHAIN_CCTP_V1_TOKEN_MESSENGER
https://uniscan.xyz/address/0x4e744b28E787c3aD0e810eD65A24461D4ac5a762
UNICHAIN_DOMAIN_ID

Traits§

CctpV1
Trait for chains that support CCTP bridging

Functions§

get_chain_confirmation_config
Gets the chain-specific confirmation configuration

Type Aliases§

AttestationBytes
The bytes of the attestation.
Result