Skip to content
Lattice

ILayerZeroGatewayAdapter

Git Source

Title: ILayerZeroGatewayAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from LayerZero v2 (https://github.com/LayerZero-Labs/LayerZero-v2)

Admin/read surface of the LayerZero v2 ERC-7786 gateway adapter. The standard source-gateway ABI (sendMessage/supportsAttribute) is on IERC7786GatewaySource; the inbound callback + path policy are ILayerZeroReceiver (lzReceive/allowInitializePath/nextNonce). EVM chains only.

LayerZero routes by uint32 endpoint id (eid), not EVM chainId — the adapter holds a bidirectional chainId ⇄ eid map and a 32-byte trusted peer per chain. Sends target the peer, which relays to the final ERC-7930 recipient encoded in the message envelope. The native fee is quoted from the endpoint and paid by msg.sender via msg.value (excess refunded); the adapter never spends Diamond funds.

Functions

endpoint

function endpoint() external view returns (address);

Returns

NameTypeDescription
<none>address

getEid

function getEid(uint256 chainId) external view returns (uint32);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint32

getChainId

function getChainId(uint32 eid) external view returns (uint256);

Parameters

NameTypeDescription
eiduint32

Returns

NameTypeDescription
<none>uint256

getPeer

function getPeer(uint256 chainId) external view returns (bytes32);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>bytes32

getDestinationGas

function getDestinationGas(uint256 chainId) external view returns (uint128);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint128

getDestinationMsgValue

function getDestinationMsgValue(uint256 chainId) external view returns (uint128);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>uint128

quoteFee

Quotes the LayerZero native fee to send payload to recipient (ERC-7930).

function quoteFee(bytes calldata recipient, bytes calldata payload) external view returns (uint256);

Parameters

NameTypeDescription
recipientbytes
payloadbytes

Returns

NameTypeDescription
<none>uint256

registerEid

Registers an EVM chainId ↔ LayerZero eid equivalence (both directions). Admin only.

function registerEid(uint256 chainId, uint32 eid) external;

Parameters

NameTypeDescription
chainIduint256
eiduint32

registerPeer

Registers a trusted 32-byte peer (remote adapter) for a chain. Admin only.

function registerPeer(uint256 chainId, bytes32 peer) external;

Parameters

NameTypeDescription
chainIduint256
peerbytes32

configureDestination

Configures a destination's executor lzReceive gas and native msg.value. Admin only.

function configureDestination(uint256 chainId, uint128 gas, uint128 msgValue) external;

Parameters

NameTypeDescription
chainIduint256
gasuint128
msgValueuint128

Events

RegisteredEid

Emitted when an EVM chainId ↔ LayerZero eid equivalence is registered.

event RegisteredEid(uint256 indexed chainId, uint32 eid);

Parameters

NameTypeDescription
chainIduint256
eiduint32

RegisteredPeer

Emitted when a trusted 32-byte peer (remote adapter) is registered for a chain.

event RegisteredPeer(uint256 indexed chainId, bytes32 peer);

Parameters

NameTypeDescription
chainIduint256
peerbytes32

ConfiguredDestination

Emitted when a destination's executor lzReceive gas / native msg.value is configured.

event ConfiguredDestination(uint256 indexed chainId, uint128 gas, uint128 msgValue);

Parameters

NameTypeDescription
chainIduint256
gasuint128
msgValueuint128

Errors

EidAlreadyRegistered

An eid equivalence is already registered for this chainId or eid.

error EidAlreadyRegistered(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

PeerAlreadyRegistered

A peer is already registered for this chain.

error PeerAlreadyRegistered(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

UnknownDestinationChain

The destination chain has no eid and/or no peer registered.

error UnknownDestinationChain(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

DestinationNotConfigured

The destination chain has no executor gas configured (call configureDestination).

error DestinationNotConfigured(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256

InsufficientFee

The native value supplied was below the quoted LayerZero native fee.

error InsufficientFee(uint256 provided, uint256 required);

Parameters

NameTypeDescription
provideduint256
requireduint256

RefundFailed

Refunding unspent native value to the sender failed.

error RefundFailed();

NotEndpoint

The inbound callback was not invoked by the configured LayerZero endpoint.

error NotEndpoint(address caller);

Parameters

NameTypeDescription
calleraddress

InvalidOriginGateway

The inbound source did not match the registered peer for its chain.

error InvalidOriginGateway(uint32 srcEid, bytes32 sender);

Parameters

NameTypeDescription
srcEiduint32
senderbytes32

MessageAlreadyExecuted

The inbound message (chainId, LayerZero guid) was already delivered (replay).

error MessageAlreadyExecuted(uint256 chainId, bytes32 guid);

Parameters

NameTypeDescription
chainIduint256
guidbytes32

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 peer misdirecting delivery).

error WrongDestinationChain(uint256 chainId);

Parameters

NameTypeDescription
chainIduint256