Message Passing (Writes)

Metalayer allows developers to send arbitrary messages between chains. This is useful for intent settlement, contract coordination, governance execution, and multi-chain applications.

Metalayer allows developers to send arbitrary messages between chains. Metalayer message passing is implemented as an extension of Hyperlane’s message-passing protocol.

arrow-up-rightHow Messages Work in Metalayer

  1. A contract on the source chain calls dispatch, sending a payload to a contract on the destination chain.

  2. Hyperlane’s relayers transport the message securely.

  3. The recipient contract processes the message by decoding it.

arrow-up-rightExample Message Passing

This example demonstrates a simple cross-chain messaging system using Metalayer. We’ll create two contracts:

  • A sender contract that dispatches messages

  • A receiver contract that counts and stores received messages

arrow-up-rightHello World Sender

The sender contract needs to:

  • Store the router address and destination information

  • Calculate gas fees for message delivery

  • Format and dispatch messages

CopyAsk AI

arrow-up-rightHello World Receiver

The receiver contract must:

  • Implement the IMetalayerRecipient interface

  • Store the router address and verify message sources

  • Track received messages

CopyAsk AI

Last updated