pub struct Cctp<P: Provider<Ethereum> + Clone> { /* private fields */ }
Expand description
CCTP v1 bridge implementation
This struct provides the core functionality for bridging USDC across chains using Circle’s Cross-Chain Transfer Protocol (CCTP).
§Example
let bridge = Cctp::builder()
.source_chain(NamedChain::Mainnet)
.destination_chain(NamedChain::Arbitrum)
.source_provider(ProviderBuilder::new().on_builtin("http://localhost:8545").await?)
.destination_provider(ProviderBuilder::new().on_builtin("http://localhost:8546").await?)
.recipient("0x...".parse()?)
.build();
Implementations§
Source§impl<P: Provider<Ethereum> + Clone> Cctp<P>
impl<P: Provider<Ethereum> + Clone> Cctp<P>
Sourcepub fn builder() -> CctpBuilder<P>
pub fn builder() -> CctpBuilder<P>
Create an instance of Cctp
using the builder syntax
Source§impl<P: Provider<Ethereum> + Clone> Cctp<P>
impl<P: Provider<Ethereum> + Clone> Cctp<P>
Sourcepub fn source_chain(&self) -> &NamedChain
pub fn source_chain(&self) -> &NamedChain
Returns the source chain
Sourcepub fn destination_chain(&self) -> &NamedChain
pub fn destination_chain(&self) -> &NamedChain
Returns the destination chain
Sourcepub fn destination_domain_id(&self) -> Result<u32>
pub fn destination_domain_id(&self) -> Result<u32>
Returns the destination domain id
Sourcepub fn source_provider(&self) -> &P
pub fn source_provider(&self) -> &P
Returns the source provider
Sourcepub fn destination_provider(&self) -> &P
pub fn destination_provider(&self) -> &P
Returns the destination provider
Sourcepub fn token_messenger_contract(&self) -> Result<Address>
pub fn token_messenger_contract(&self) -> Result<Address>
Returns the CCTP token messenger contract, the address of the contract that handles the deposit and burn of USDC
Sourcepub fn message_transmitter_contract(&self) -> Result<Address>
pub fn message_transmitter_contract(&self) -> Result<Address>
Returns the CCTP message transmitter contract, the address of the contract that handles the receipt of messages
Sourcepub fn iris_api_url(&self, message_hash: &FixedBytes<32>) -> String
pub fn iris_api_url(&self, message_hash: &FixedBytes<32>) -> String
Sourcepub async fn get_message_sent_event(
&self,
tx_hash: TxHash,
) -> Result<(Vec<u8>, FixedBytes<32>)>
pub async fn get_message_sent_event( &self, tx_hash: TxHash, ) -> Result<(Vec<u8>, FixedBytes<32>)>
Sourcepub async fn get_attestation_with_retry(
&self,
message_hash: FixedBytes<32>,
max_attempts: Option<u32>,
poll_interval: Option<u64>,
) -> Result<AttestationBytes>
pub async fn get_attestation_with_retry( &self, message_hash: FixedBytes<32>, max_attempts: Option<u32>, poll_interval: Option<u64>, ) -> Result<AttestationBytes>
Gets the attestation for a message hash from the CCTP API
§Arguments
message_hash
: The hash of the message to get the attestation formax_attempts
: Maximum number of polling attempts (default: 30)poll_interval
: Time to wait between polling attempts in seconds (default: 60)
§Returns
The attestation bytes if successful
Sourcepub fn create_url(&self, message_hash: FixedBytes<32>) -> String
pub fn create_url(&self, message_hash: FixedBytes<32>) -> String
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Cctp<P>where
P: Freeze,
impl<P> RefUnwindSafe for Cctp<P>where
P: RefUnwindSafe,
impl<P> Send for Cctp<P>
impl<P> Sync for Cctp<P>
impl<P> Unpin for Cctp<P>where
P: Unpin,
impl<P> UnwindSafe for Cctp<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more