Struct Cctp

Source
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>

Source

pub fn builder() -> CctpBuilder<P>

Create an instance of Cctp using the builder syntax

Source§

impl<P: Provider<Ethereum> + Clone> Cctp<P>

Source

pub fn api_url(&self) -> &'static str

Returns the CCTP API URL for the current environment

Source

pub fn source_chain(&self) -> &NamedChain

Returns the source chain

Source

pub fn destination_chain(&self) -> &NamedChain

Returns the destination chain

Source

pub fn destination_domain_id(&self) -> Result<u32>

Returns the destination domain id

Source

pub fn source_provider(&self) -> &P

Returns the source provider

Source

pub fn destination_provider(&self) -> &P

Returns the destination provider

Source

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

Source

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

Source

pub fn recipient(&self) -> &Address

Returns the recipient address

Source

pub fn iris_api_url(&self, message_hash: &FixedBytes<32>) -> String

Constructs the Iris API URL for a given message hash

§Arguments
  • message_hash - The message hash to query
§Returns

The full URL to query the attestation status

Source

pub async fn get_message_sent_event( &self, tx_hash: TxHash, ) -> Result<(Vec<u8>, FixedBytes<32>)>

Gets the MessageSent event data from a CCTP bridge transaction

§Arguments
  • tx_hash: The hash of the transaction to get the MessageSent event for
§Returns

Returns the message bytes and its hash

Source

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 for
  • max_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

Source

pub fn create_url(&self, message_hash: FixedBytes<32>) -> String

Source

pub async fn get_attestation( &self, client: &Client, url: &str, ) -> Result<Response>

Gets the attestation for a message hash from the CCTP API

§Arguments
  • client: The HTTP client to use
  • url: The URL to get the attestation from

Trait Implementations§

Source§

impl<P: Clone + Provider<Ethereum> + Clone> Clone for Cctp<P>

Source§

fn clone(&self) -> Cctp<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + Provider<Ethereum> + Clone> Debug for Cctp<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,