Skip to main content

Mailbox

Hyperlane's generalized message passing (GMP) interface is implemented as a smart contract called the Mailbox. This contract encodes and decodes message headers, ensures global message uniqueness, and prevents replay attacks.

Message Headers

The Mailbox prepends message bodies with a header containing the following fields:

  • version: The version of the Mailbox contract
  • nonce: A unique identifier for each message sent from a given Mailbox
  • origin: The domain of the origin chain
  • sender: The address of the sender on the origin chain
  • destination: The domain of the destination chain
  • recipient: The address of the recipient on the destination chain

See the Message library for more information on the message encoding.

Uniqueness

The nonce is a monotonically increasing integer for each message sent from a given Mailbox. It is incremented each time a message is dispatched to serve as a separator for otherwise identical messages.

function delivered(bytes32 messageId) external view returns (bool);

The messageId is a globally unique message identifier, returned from the dispatch call, computed as the keccak256 hash of the message (with headers).

Replay Protection

The Mailbox maintains a mapping of already delivered messageId values to prevent replay attacks. If a message is received with a messageId that has already been delivered, the message is rejected.

function defaultIsm() external view returns (IInterchainSecurityModule);