Skip to main content

Overview

The IRelayer 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)

Source: src/interfaces/IRelayer.sol:22

IRelayerV2

V2 simplifies the interface with a single unified send function that includes finality parameters:
Source: src/interfaces/v2/IRelayerV2.sol:24

Functions

sendMessage (V1)

Sends an outgoing message to the destination domain, allowing any caller to deliver it. Parameters:
  • destinationDomain - The domain ID of the destination chain
  • recipient - The address of the message recipient on the destination domain (as bytes32)
  • messageBody - The raw bytes content of the message payload
Returns:
  • The nonce reserved for this message
Behavior:
  • Increments the nonce counter
  • Formats the complete message with header
  • Emits MessageSent event for attesters to observe
  • Any address can call receiveMessage on the destination

sendMessageWithCaller (V1)

Sends an outgoing message with a restricted destination caller. Parameters:
  • destinationDomain - The domain ID of the destination chain
  • recipient - 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
Returns:
  • The nonce reserved for this message
Warning: If 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)

Replaces a previously sent message with a new message body and/or destination caller. Parameters:
  • originalMessage - The original message bytes to replace
  • originalAttestation - Valid attestation of the original message
  • newMessageBody - The new message body content
  • newDestinationCaller - The new destination caller (or bytes32(0) for any caller)
Requirements:
  • originalAttestation must be a valid attestation of originalMessage
  • Original message must not have been received yet on destination
  • Replacement reuses the original message’s nonce
Use Cases:
  • Update recipient address before message is delivered
  • Change destination caller permissions
  • Modify message content while preserving nonce

sendMessage (V2)

Sends an outgoing message with finality requirements. Parameters:
  • destinationDomain - The domain ID of the destination chain
  • recipient - The message recipient address (as bytes32)
  • destinationCaller - Allowed caller on destination (bytes32(0) for any caller)
  • minFinalityThreshold - Minimum finality threshold for attestation
  • messageBody - The message payload
Warning: If 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

  1. Message Observation
    • Monitor MessageSent events on source chains
    • Track messages that need delivery
  2. Attestation Retrieval
    • Query Circle’s attestation API
    • Wait for attestation to be available
    • Verify attestation validity
  3. Message Delivery
    • Call receiveMessage() on destination chain
    • Include message and attestation as parameters
    • Pay gas costs for destination transaction
  4. Status Tracking
    • Monitor delivery success/failure
    • Handle retries if needed
    • Track delivery receipts

MessageSent Event

Emitted when a message is sent, containing the complete formatted message:
Relayers parse this event to:
  • 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)
Option 2: Fee-on-delivery (V2)
Option 3: Sponsored (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