IL2ToL2CrossDomainMessenger
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
| Name | Type | Description |
|---|---|---|
| _destination | uint256 | Destination chain id. |
| _target | address | Target contract/wallet on the destination chain. |
| _message | bytes | Message payload to call _target with. |
Returns
| Name | Type | Description |
|---|---|---|
| messageHash_ | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
| _id | Identifier | Identifier of the SentMessage event log to relay. |
| _sentMessage | bytes | The message payload (the ABI-encoded SentMessage event data). |
Returns
| Name | Type | Description |
|---|---|---|
| returnData_ | bytes | The 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
| Name | Type | Description |
|---|---|---|
| sender_ | address | The account (on the source chain) that sent the message. |
| source_ | uint256 | The chain id of the source chain. |
crossDomainMessageSender
Retrieves the sender of the message currently being relayed.
function crossDomainMessageSender() external view returns (address sender_);Returns
| Name | Type | Description |
|---|---|---|
| sender_ | address |
crossDomainMessageSource
Retrieves the source chain id of the message currently being relayed.
function crossDomainMessageSource() external view returns (uint256 source_);Returns
| Name | Type | Description |
|---|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| _ | bytes32 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
messageVersion
The version of the message encoding this messenger produces.
function messageVersion() external view returns (uint16);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint16 |
messageNonce
The next message nonce this messenger will assign.
function messageNonce() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |