Overview
TheIRelayer interface defines the contract for sending cross-chain messages from the source domain to destination domains. It manages message formatting, nonce assignment, and event emission to enable off-chain attestation and delivery.
Interface Definition
IRelayer (V1)
src/interfaces/IRelayer.sol:22
IRelayerV2
V2 simplifies the interface with a single unified send function that includes finality parameters:src/interfaces/v2/IRelayerV2.sol:24
Functions
sendMessage (V1)
destinationDomain- The domain ID of the destination chainrecipient- The address of the message recipient on the destination domain (as bytes32)messageBody- The raw bytes content of the message payload
- The nonce reserved for this message
- Increments the nonce counter
- Formats the complete message with header
- Emits
MessageSentevent for attesters to observe - Any address can call
receiveMessageon the destination
sendMessageWithCaller (V1)
destinationDomain- The domain ID of the destination chainrecipient- The address of the message recipient (as bytes32)destinationCaller- The only address allowed to deliver this message (as bytes32)messageBody- The raw bytes content of the message
- The nonce reserved for this message
destinationCaller does not represent a valid address, the message cannot be delivered on the destination domain. Use the standard sendMessage() when a specific caller is not required.
replaceMessage (V1)
originalMessage- The original message bytes to replaceoriginalAttestation- Valid attestation of the original messagenewMessageBody- The new message body contentnewDestinationCaller- The new destination caller (or bytes32(0) for any caller)
originalAttestationmust be a valid attestation oforiginalMessage- Original message must not have been received yet on destination
- Replacement reuses the original message’s nonce
- Update recipient address before message is delivered
- Change destination caller permissions
- Modify message content while preserving nonce
sendMessage (V2)
destinationDomain- The domain ID of the destination chainrecipient- The message recipient address (as bytes32)destinationCaller- Allowed caller on destination (bytes32(0) for any caller)minFinalityThreshold- Minimum finality threshold for attestationmessageBody- The message payload
destinationCaller is not a valid address as bytes32, the message cannot be delivered. Use bytes32(0) to allow any caller.
Relayer Role in Message Delivery
Message Lifecycle
Relayer Responsibilities
-
Message Observation
- Monitor
MessageSentevents on source chains - Track messages that need delivery
- Monitor
-
Attestation Retrieval
- Query Circle’s attestation API
- Wait for attestation to be available
- Verify attestation validity
-
Message Delivery
- Call
receiveMessage()on destination chain - Include message and attestation as parameters
- Pay gas costs for destination transaction
- Call
-
Status Tracking
- Monitor delivery success/failure
- Handle retries if needed
- Track delivery receipts
MessageSent Event
- Extract message hash for attestation API
- Get destination domain for routing
- Identify recipient and caller restrictions
Fee Handling in V2
Relayer Fee Model
V2 introduces built-in support for relayer fees through multi-recipient minting:Fee Distribution on Destination
Dynamic Fee Calculation
Relayers can implement dynamic fee models:Fee Payment Options
Option 1: Pre-paid (V1 & V2)Usage Examples
Basic Message Send (V1)
Restricted Caller (V1)
Message Replacement (V1)
Finality-Aware Send (V2)
Security Considerations
Nonce Management
- Each message receives a unique, incrementing nonce
- Nonces prevent replay attacks
- Nonce is included in message hash for attestation
Destination Caller Validation
Message Immutability
- Once attested, message content is cryptographically sealed
- Replacement creates new attestation for same nonce
- First delivered message at a nonce wins
Domain Validation
- Destination domain must be registered and supported
- Source domain is automatically set to local domain
- Cross-domain validation prevents misrouting
Related Interfaces
- IReceiver - Receives messages sent by relayers
- IMessageHandler - Processes message content after receipt
- MessageTransmitter - Implements IRelayer for CCTP