Skip to content
Lattice

IL2ToL2CrossDomainMessenger

Git Source

Title: IL2ToL2CrossDomainMessenger (OP Superchain) — vendored subset

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

Minimal vendored subset of the OP Superchain L2ToL2CrossDomainMessenger predeploy — the same-domain (L2→L2) messenger that lets contracts on one Superchain chain call contracts on another, routed purely by destination chainId. sendMessage enqueues an outbound message; relayMessage (invoked by a relayer on the destination chain) executes it against the _target, exposing the authenticated cross-domain (sender, source) via crossDomainMessageContext for the duration of the call.

VERIFIED minimal OP Superchain interface subset — canonical: ethereum-optimism/optimism packages/contracts-bedrock/.../L2ToL2CrossDomainMessenger.sol (MIT). Signatures vendored VERBATIM (not invented) and re-declared at pragma ^0.8.30 — do NOT add an optimism dependency. The predeploy lives at a fixed address on every OP Superchain chain: L2_TO_L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000023.

NOTE: Superchain interop is PRE-MAINNET. Both the predeploy address AND the message encoding MUST be re-verified against the then-current contracts-bedrock release before ANY production deploy.

Note:

  • lattice-source: Optimism

Functions

sendMessage

Sends a message to _target on chain _destination, to be relayed by relayMessage.

function sendMessage(uint256 _destination, address _target, bytes calldata _message)
        external
        returns (bytes32 messageHash_);

Parameters

NameTypeDescription
_destinationuint256Destination chain id.
_targetaddressTarget contract/wallet on the destination chain.
_messagebytesMessage payload to call _target with.

Returns

NameTypeDescription
messageHash_bytes32The hash of the message, used to track its status.

relayMessage

Relays a message that was sent by the source-chain L2ToL2CrossDomainMessenger.

function relayMessage(Identifier calldata _id, bytes calldata _sentMessage)
        external
        payable
        returns (bytes memory returnData_);

Parameters

NameTypeDescription
_idIdentifierIdentifier of the SentMessage event log to relay.
_sentMessagebytesThe message payload (the ABI-encoded SentMessage event data).

Returns

NameTypeDescription
returnData_bytesThe return data of the target call.

crossDomainMessageContext

Retrieves the sender AND source of the message currently being relayed (in the target's context).

function crossDomainMessageContext() external view returns (address sender_, uint256 source_);

Returns

NameTypeDescription
sender_addressThe account (on the source chain) that sent the message.
source_uint256The chain id of the source chain.

crossDomainMessageSender

Retrieves the sender of the message currently being relayed.

function crossDomainMessageSender() external view returns (address sender_);

Returns

NameTypeDescription
sender_address

crossDomainMessageSource

Retrieves the source chain id of the message currently being relayed.

function crossDomainMessageSource() external view returns (uint256 source_);

Returns

NameTypeDescription
source_uint256

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

messageVersion

The version of the message encoding this messenger produces.

function messageVersion() external view returns (uint16);

Returns

NameTypeDescription
<none>uint16

messageNonce

The next message nonce this messenger will assign.

function messageNonce() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256