Skip to content
Lattice

IL2ToL2CrossDomainMessengerGatewayAdapter

Git Source

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

NameTypeDescription
<none>address

getRemoteAdapter

The trusted remote gateway adapter registered for chainId (0 = unset).

function getRemoteAdapter(uint256 chainId) external view returns (address);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<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

NameTypeDescription
senderbytesThe ERC-7930 sender interoperable address (origin chain + caller).
recipientbytesThe ERC-7930 recipient interoperable address (must target THIS chain).
payloadbytesThe opaque message payload delivered to the recipient.
nonceuint256The 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

NameTypeDescription
chainIduint256
remoteAdapteraddress

Events

RegisteredRemoteAdapter

Emitted when a trusted remote gateway adapter is registered for a chain.

event RegisteredRemoteAdapter(uint256 indexed chainId, address remoteAdapter);

Parameters

NameTypeDescription
chainIduint256
remoteAdapteraddress

Errors

RemoteAdapterAlreadyRegistered

A remote adapter is already registered for this chain (registration is one-shot).

error RemoteAdapterAlreadyRegistered(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

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

NameTypeDescription
chainIduint256

UnexpectedValue

A non-empty msg.value was supplied to sendMessage; the messenger takes no native fee.

error UnexpectedValue(uint256 value);

Parameters

NameTypeDescription
valueuint256

NotMessenger

The inbound callback was not invoked by the L2ToL2CrossDomainMessenger predeploy.

error NotMessenger(address caller);

Parameters

NameTypeDescription
calleraddress

InvalidOriginGateway

The authenticated cross-domain (source, sender) did not match the registered remote adapter.

error InvalidOriginGateway(uint256 source, address sender);

Parameters

NameTypeDescription
sourceuint256
senderaddress

MessageAlreadyExecuted

The inbound message was already delivered (replay defense-in-depth atop the messenger self-dedup).

error MessageAlreadyExecuted(uint256 source, bytes32 id);

Parameters

NameTypeDescription
sourceuint256
idbytes32

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

NameTypeDescription
chainIduint256