cctp-rs
A production-ready Rust implementation of Circle's Cross-Chain Transfer Protocol (CCTP), enabling seamless USDC transfers across blockchain networks.
Features
- 🚀 Type-safe contract interactions using Alloy
- 🔄 Multi-chain support for 26+ mainnet and testnet networks
- 📦 Builder pattern for intuitive API usage
- ⚡ CCTP v2 support with fast transfers (<30s settlement)
- 🎯 Programmable hooks for advanced use cases
- 🔍 Comprehensive observability with OpenTelemetry integration
Supported Chains
CCTP v2 (Current)
Mainnet
- Ethereum, Arbitrum, Base, Optimism, Avalanche, Polygon, Unichain
- Linea, Sonic, Sei (v2-only chains)
Testnet
- Sepolia, Arbitrum Sepolia, Base Sepolia, Optimism Sepolia
- Avalanche Fuji, Polygon Amoy
CCTP v1 (Legacy)
Also supported for backwards compatibility
Quick Start
Add to your Cargo.toml:
[]
= "0.13.0"
Basic Example
use ;
use NamedChain;
use ;
use ;
async
Bridging USDC
use ;
use NamedChain;
use ;
async
Architecture
The library is organized into several key modules:
bridge- Core CCTP bridge implementationchain- Chain-specific configurations and supportattestation- Attestation response types from Circle's Iris APIerror- Comprehensive error types for proper error handlingcontracts- Type-safe bindings for TokenMessenger and MessageTransmitter
Error Handling
cctp-rs provides detailed error types for different failure scenarios:
use ;
match bridge.get_attestation.await
Advanced Usage
Custom Polling Configuration
// Wait up to 10 minutes with 30-second intervals
let attestation = bridge.get_attestation.await?;
Chain Configuration
use CctpV1;
use NamedChain;
// Get chain-specific information
let chain = Arbitrum;
let confirmation_time = chain.confirmation_average_time_seconds?;
let domain_id = chain.cctp_domain_id?;
let token_messenger = chain.token_messenger_address?;
println!;
println!;
println!;
Examples
Check out the examples/ directory for complete working examples:
CCTP v2 Examples
v2_integration_validation.rs- Comprehensive v2 validation (no network required)v2_standard_transfer.rs- Standard transfer with finalityv2_fast_transfer.rs- Fast transfer (<30s settlement)
CCTP v1 Examples (Legacy)
basic_bridge.rs- Simple USDC bridge exampleattestation_monitoring.rs- Monitor attestation statusmulti_chain.rs- Bridge across multiple chains
Run examples with:
# Recommended: Run v2 integration validation
# Or run specific examples
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Testing
Unit Tests
Run the full test suite with:
All 149 unit tests validate:
- Contract method selection logic
- Domain ID resolution and mapping
- Configuration validation
- URL construction for Circle's Iris API
- Error handling and edge cases
- Cross-chain compatibility
- Fast transfer support
- Hooks integration
Integration Validation
We provide comprehensive runnable examples that validate the complete v2 API without requiring network access:
# Validate all v2 configurations (no network required)
# Educational examples showing complete flows
The v2_integration_validation example validates:
- Chain support matrix (26+ chains)
- Domain ID mappings against Circle's official values
- Contract address consistency (unified v2 addresses)
- Bridge configuration variations (standard, fast, hooks)
- API endpoint construction (mainnet vs testnet)
- Fast transfer support and fee structures
- Error handling for unsupported chains
- Cross-chain compatibility
Live Testnet Testing
For pre-release validation on testnet:
- Get testnet tokens from Circle's faucet
- Update examples with your addresses and RPC endpoints
- Set environment variables for private keys
- Execute and monitor the full flow
Note: Integration tests requiring Circle's Iris API and live blockchains are not run in CI due to:
- Cost (gas fees on every test run)
- Time (10-15 minutes per transfer for attestation)
- Flakiness (network dependencies and rate limits)
- Complexity (requires funded wallets with private keys)
Instead, we validate via extensive unit tests and runnable examples. This approach ensures reliability while maintaining fast CI/CD pipelines.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Acknowledgments
- Circle for creating CCTP
- Alloy for the excellent Ethereum libraries
- The Rust community for amazing tools and support