Message Cross-chain

Send cross-chain messages to call contracts or sync data across chains.

Overview

MOS Message enables:

  • Call contracts on chain B from chain A

  • Sync data changes from chain A to chain B

MOS uses MAP Protocol Light Client to verify cross-chain message transactions, ensuring authenticity and on-chain traceability.

Prerequisites

  • Application must be on a MAP Protocol supported chain

  • Cross-chain executable contract must authorize the MOS contract

  • Both source and destination chains must have MOS Message contracts deployed

How It Works

On Source Chain

  1. DApp prepares cross-chain message and target chain callData

  2. DApp calls MOS transferOut method, paying cross-chain gas fee

  3. MOS emits cross-chain message log

On MAP Relay Chain

  1. Messenger detects message log on source chain

  2. Messenger builds proof data and calls transferIn on MOS Relay

  3. MOS Relay verifies via Light Client

  4. If MAP Relay Chain is destination, executes call; otherwise emits new event

On Destination Chain

  1. Messenger detects message log on MAP Relay Chain

  2. Messenger builds proof and calls transferIn on destination MOS

  3. MOS verifies message via Light Client

  4. Executes cross-chain contract call

Message Types

CALLDATA Mode

Target contract method is called directly with encoded calldata.

MESSAGE Mode

Target contract must implement IMapoExecutor interface:

Contract Interface

Usage Example

Send Cross-chain Message (CALLDATA Mode)

Receive Cross-chain Message (Target Contract)

Security

Before receiving cross-chain messages, the target contract must:

  1. Call addRemoteCaller to trust the source chain contract address

  2. Verify msg.sender == mos in receiving functions

Complete Tutorial

See Build OmniApparrow-up-right for a complete step-by-step tutorial.

Last updated