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 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) -> Address
pub fn sender_address(&self) -> Address
Returns the EVM sender address encoded in the 32-byte sender field.
This helper assumes the source domain uses the EVM trailing-20-byte
convention for bytes32 addresses. For non-EVM domains, the raw
Self::sender field is authoritative.
Sourcepub fn recipient_address(&self) -> Address
pub fn recipient_address(&self) -> Address
Returns the EVM recipient address encoded in the 32-byte recipient field.
This helper assumes the destination domain uses the EVM trailing-20-byte
convention for bytes32 addresses. For non-EVM domains, the raw
Self::recipient field is authoritative.
Sourcepub fn destination_caller_address(&self) -> Option<Address>
pub fn destination_caller_address(&self) -> Option<Address>
Returns the destination caller as an EVM address if the message is not permissionless.
This helper assumes the destination domain uses the EVM trailing-20-byte
convention for bytes32 addresses. For non-EVM domains, the raw
Self::destination_caller field is authoritative.
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 · 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>,
Source§impl PartialEq for MessageHeader
impl PartialEq for MessageHeader
Source§impl Serialize for MessageHeader
impl Serialize for MessageHeader
impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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