pub struct MessageHeader {
pub version: u32,
pub source_domain: DomainId,
pub destination_domain: DomainId,
pub nonce: FixedBytes<32>,
pub sender: FixedBytes<32>,
pub recipient: FixedBytes<32>,
pub destination_caller: FixedBytes<32>,
pub min_finality_threshold: u32,
pub finality_threshold_executed: u32,
}Expand description
CCTP v2 Message Header
The message header contains metadata about cross-chain messages, including source/destination domains, finality requirements, and routing.
§Format
- version: uint32 (4 bytes)
- sourceDomain: uint32 (4 bytes)
- destinationDomain: uint32 (4 bytes)
- nonce: bytes32 (32 bytes) - unique identifier assigned by Circle
- sender: bytes32 (32 bytes) - message sender address
- recipient: bytes32 (32 bytes) - message recipient address
- destinationCaller: bytes32 (32 bytes) - authorized caller on destination
- minFinalityThreshold: uint32 (4 bytes) - minimum required finality
- finalityThresholdExecuted: uint32 (4 bytes) - actual finality level
Total fixed size: 4 + 4 + 4 + 32 + 32 + 32 + 32 + 4 + 4 = 148 bytes
Fields§
§version: u32Message format version
source_domain: DomainIdSource blockchain domain ID
destination_domain: DomainIdDestination blockchain domain ID
nonce: FixedBytes<32>Unique message nonce assigned by Circle
sender: FixedBytes<32>Address that sent the message (padded to 32 bytes)
recipient: FixedBytes<32>Address that will receive the message (padded to 32 bytes)
destination_caller: FixedBytes<32>Address authorized to call receiveMessage on destination (0 = anyone)
min_finality_threshold: u32Minimum finality threshold required (1000 = Fast, 2000 = Standard)
finality_threshold_executed: u32Actual finality threshold when message was attested
Implementations§
Source§impl MessageHeader
impl MessageHeader
Sourcepub const SUPPORTED_VERSION: u32 = CCTP_V2_MESSAGE_VERSION
pub const SUPPORTED_VERSION: u32 = CCTP_V2_MESSAGE_VERSION
The only CCTP v2 message header version this parser understands.
Sourcepub fn new(
version: u32,
source_domain: DomainId,
destination_domain: DomainId,
nonce: FixedBytes<32>,
sender: FixedBytes<32>,
recipient: FixedBytes<32>,
destination_caller: FixedBytes<32>,
min_finality_threshold: u32,
finality_threshold_executed: u32,
) -> Self
pub fn new( version: u32, source_domain: DomainId, destination_domain: DomainId, nonce: FixedBytes<32>, sender: FixedBytes<32>, recipient: FixedBytes<32>, destination_caller: FixedBytes<32>, min_finality_threshold: u32, finality_threshold_executed: u32, ) -> Self
Creates a new message header
Sourcepub fn encode(&self) -> Bytes
pub fn encode(&self) -> Bytes
Encodes the message header to bytes
The encoding follows Circle’s v2 message format specification.
Sourcepub fn decode(bytes: &[u8]) -> Option<Self>
pub fn decode(bytes: &[u8]) -> Option<Self>
Decodes a message header from bytes
Returns None if the bytes are not at least MessageHeader::SIZE bytes long
or if domain IDs are invalid.
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, ParseMessageError>
pub fn parse(bytes: &[u8]) -> Result<Self, ParseMessageError>
Parses a message header and returns a descriptive error on failure.
Sourcepub fn has_placeholder_nonce(&self) -> bool
pub fn has_placeholder_nonce(&self) -> bool
Returns true when the nonce is still the placeholder zero value from the on-chain event.
Sourcepub fn sender_address(&self) -> Option<Address>
pub fn sender_address(&self) -> Option<Address>
Returns the sender as an EVM Address when the source domain is EVM.
Returns None for non-EVM domains such as DomainId::Solana or
DomainId::StarknetTestnet, whose bytes32 sender words do not use
the EVM trailing-20-byte convention. For those domains, the raw
Self::sender field is the canonical source of truth.
Sourcepub fn recipient_address(&self) -> Option<Address>
pub fn recipient_address(&self) -> Option<Address>
Returns the recipient as an EVM Address when the destination domain is EVM.
Returns None for non-EVM destination domains. For those, the raw
Self::recipient field is the canonical source of truth.
Sourcepub fn destination_caller_address(&self) -> Option<Address>
pub fn destination_caller_address(&self) -> Option<Address>
Returns the destination caller as an EVM Address when one is set and
the destination domain is EVM.
Returns None when the message is permissionless or the destination
domain is non-EVM. The raw Self::destination_caller field is
authoritative in the non-EVM case.
Sourcepub fn is_permissionless(&self) -> bool
pub fn is_permissionless(&self) -> bool
Returns true when the message can be relayed by anyone.
Sourcepub fn requested_finality(&self) -> Option<FinalityThreshold>
pub fn requested_finality(&self) -> Option<FinalityThreshold>
Returns the requested finality threshold when it matches a known CCTP mode.
Sourcepub fn attested_finality(&self) -> Option<FinalityThreshold>
pub fn attested_finality(&self) -> Option<FinalityThreshold>
Returns the finality threshold that Circle actually used for the attestation.
Trait Implementations§
Source§impl Clone for MessageHeader
impl Clone for MessageHeader
Source§fn clone(&self) -> MessageHeader
fn clone(&self) -> MessageHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageHeader
impl Debug for MessageHeader
Source§impl<'de> Deserialize<'de> for MessageHeader
impl<'de> Deserialize<'de> for MessageHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MessageHeader
Source§impl PartialEq for MessageHeader
impl PartialEq for MessageHeader
Source§impl Serialize for MessageHeader
impl Serialize for MessageHeader
impl StructuralPartialEq for MessageHeader
Auto Trait Implementations§
impl Freeze for MessageHeader
impl RefUnwindSafe for MessageHeader
impl Send for MessageHeader
impl Sync for MessageHeader
impl Unpin for MessageHeader
impl UnsafeUnpin for MessageHeader
impl UnwindSafe for MessageHeader
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
impl<'de, T> BorrowedRpcObject<'de> for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> ⓘ
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> ⓘ
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