IL2ToL2CrossDomainMessengerGatewayAdapter
Title: IL2ToL2CrossDomainMessengerGatewayAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Optimism (https://github.com/ethereum-optimism/optimism)
Admin/read surface of the OP Superchain L2ToL2CrossDomainMessenger ERC-7786 gateway adapter. The
standard source-gateway ABI (sendMessage/supportsAttribute) is on IERC7786GatewaySource; the
inbound delivery callback the messenger invokes on the destination adapter is
receiveCrossChainMessage. EVM (Superchain) chains only.
Unlike the CCIP / LayerZero siblings there is NO native-id translation: the messenger routes by BARE EVM
chainId, so the trusted-remote registry is a single mapping(chainId => remoteAdapter) — the sibling
adapter on that chain. Sends target the remote adapter, which relays to the final ERC-7930 recipient
encoded in the message envelope. No fee is taken: gas is supplied by the relayer at relayMessage, and
the messenger itself charges no native value, so sendMessage rejects a non-empty msg.value.
INVERTED INBOUND AUTH (vs. the siblings' "gateway is msg.sender" model): the adapter's inbound function
is the _target the messenger CALLS during relayMessage, so msg.sender is the messenger predeploy —
not the remote gateway. The trusted-remote check is therefore read back out-of-band from the messenger's
crossDomainMessageContext() (the authenticated (sender, source)), NOT from msg.sender.
Functions
messenger
The fixed OP Superchain L2ToL2CrossDomainMessenger predeploy this adapter sends to / accepts
deliveries from (0x4200000000000000000000000000000000000023).
function messenger() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
getRemoteAdapter
The trusted remote gateway adapter registered for chainId (0 = unset).
function getRemoteAdapter(uint256 chainId) external view returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
receiveCrossChainMessage
Inbound delivery callback the messenger invokes on THIS adapter during relayMessage. Authenticates
the messenger + the authenticated cross-domain (source, sender) against the registered remote
adapter, de-dups, then hands off to the ERC-7930 recipient via the IERC7786Recipient handshake.
function receiveCrossChainMessage(
bytes calldata sender,
bytes calldata recipient,
bytes calldata payload,
uint256 nonce
) external;Parameters
| Name | Type | Description |
|---|---|---|
| sender | bytes | The ERC-7930 sender interoperable address (origin chain + caller). |
| recipient | bytes | The ERC-7930 recipient interoperable address (must target THIS chain). |
| payload | bytes | The opaque message payload delivered to the recipient. |
| nonce | uint256 | The source-minted monotonic nonce; (source, nonce) forms the globally-unique delivery id. |
registerRemoteAdapter
Registers a trusted remote gateway adapter (the sibling adapter) for a chain. One-shot. Admin only.
function registerRemoteAdapter(uint256 chainId, address remoteAdapter) external;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| remoteAdapter | address |
Events
RegisteredRemoteAdapter
Emitted when a trusted remote gateway adapter is registered for a chain.
event RegisteredRemoteAdapter(uint256 indexed chainId, address remoteAdapter);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| remoteAdapter | address |
Errors
RemoteAdapterAlreadyRegistered
A remote adapter is already registered for this chain (registration is one-shot).
error RemoteAdapterAlreadyRegistered(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
InvalidRemoteAdapter
A zero address was supplied as a remote adapter.
error InvalidRemoteAdapter();UnknownDestinationChain
The destination chain has no remote adapter registered.
error UnknownDestinationChain(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
UnexpectedValue
A non-empty msg.value was supplied to sendMessage; the messenger takes no native fee.
error UnexpectedValue(uint256 value);Parameters
| Name | Type | Description |
|---|---|---|
| value | uint256 |
NotMessenger
The inbound callback was not invoked by the L2ToL2CrossDomainMessenger predeploy.
error NotMessenger(address caller);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address |
InvalidOriginGateway
The authenticated cross-domain (source, sender) did not match the registered remote adapter.
error InvalidOriginGateway(uint256 source, address sender);Parameters
| Name | Type | Description |
|---|---|---|
| source | uint256 | |
| sender | address |
MessageAlreadyExecuted
The inbound message was already delivered (replay defense-in-depth atop the messenger self-dedup).
error MessageAlreadyExecuted(uint256 source, bytes32 id);Parameters
| Name | Type | Description |
|---|---|---|
| source | uint256 | |
| id | bytes32 |
RecipientExecutionFailed
The recipient's receiveMessage did not return the ERC-7786 magic value.
error RecipientExecutionFailed();WrongDestinationChain
The inbound message's ERC-7930 recipient targets a different chain than this one (defense-in-depth against a rogue/misconfigured trusted remote adapter misdirecting delivery).
error WrongDestinationChain(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |