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 mainnet and testnet networks
- 📦 Builder pattern for intuitive API usage
Supported Chains
Mainnet
- Ethereum
- Arbitrum
- Base
- Optimism
- Avalanche
- Polygon
- Unichain
Testnet
- Sepolia
- Arbitrum Sepolia
- Base Sepolia
- Optimism Sepolia
- Avalanche Fuji
- Polygon Amoy
Quick Start
Add to your Cargo.toml:
[]
= "0.3.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:
basic_bridge.rs- Simple USDC bridge exampleattestation_monitoring.rs- Monitor attestation statusmulti_chain.rs- Bridge across multiple chains
Run examples with:
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 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Testing
Run the test suite:
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