Skip to content
Lattice

ICrossDomainMessenger

Git Source

Title: ICrossDomainMessenger (OP Stack, canonical L1<->L2) — vendored subset

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Vendored minimal subset of Optimism's CrossDomainMessenger (https://github.com/ethereum-optimism/optimism). Upstream license: MIT.

Minimal vendored subset of the canonical OP Stack CrossDomainMessenger — the CANONICAL L1<->L2 messenger (L1CrossDomainMessenger on L1, L2CrossDomainMessenger predeploy on L2) that carries deposits (L1->L2) and withdrawals (L2->L1). sendMessage enqueues an outbound message to the paired domain; the paired messenger delivers it by CALLing _target with _message, exposing the authenticated counterpart sender via xDomainMessageSender for the duration of that call.

VERIFIED minimal canonical OP L1<->L2 messenger interface — canonical source: ethereum-optimism/optimism packages/contracts-bedrock/.../universal/CrossDomainMessenger.sol (MIT). Signatures vendored VERBATIM (not invented) and re-declared at pragma ^0.8.30 — do NOT add an optimism dependency. The L2 predeploy lives at a fixed address on every OP Stack chain: L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007.

NOTE: L2->L1 (withdrawal) messages finalize only AFTER the withdrawal challenge window; that timing is handled off-chain by the messenger / portal and is invisible to this adapter, which is direction-agnostic.

Note:

  • lattice-source: Optimism

Functions

sendMessage

Sends a message to _target on the paired (other) domain, relayed by the counterpart messenger.

VOID — the canonical messenger returns nothing (the message hash is derived off-chain / from events).

function sendMessage(address _target, bytes calldata _message, uint32 _minGasLimit) external payable;

Parameters

NameTypeDescription
_targetaddressTarget contract/wallet on the other domain.
_messagebytesMessage payload to call _target with.
_minGasLimituint32Minimum gas limit the message is relayed with on the other domain.

xDomainMessageSender

The authenticated counterpart sender of the message currently being relayed (INVERTED AUTH: read in the _target's context during delivery). Equals a sentinel when no message is being relayed.

function xDomainMessageSender() external view returns (address);

Returns

NameTypeDescription
<none>address

otherMessenger

The messenger on the paired domain that this messenger sends to / receives from.

function otherMessenger() external view returns (ICrossDomainMessenger);

Returns

NameTypeDescription
<none>ICrossDomainMessenger

successfulMessages

Whether a message (by hash) has already been successfully relayed (self-dedup / replay guard).

function successfulMessages(bytes32) external view returns (bool);

Parameters

NameTypeDescription
_bytes32

Returns

NameTypeDescription
<none>bool

messageNonce

The next message nonce this messenger will assign.

function messageNonce() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256

MESSAGE_VERSION

The version of the message encoding this messenger produces.

function MESSAGE_VERSION() external view returns (uint16);

Returns

NameTypeDescription
<none>uint16