ILayerZeroGatewayAdapter
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
| Name | Type | Description |
|---|---|---|
| <none> | address |
getEid
function getEid(uint256 chainId) external view returns (uint32);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint32 |
getChainId
function getChainId(uint32 eid) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| eid | uint32 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getPeer
function getPeer(uint256 chainId) external view returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 |
getDestinationGas
function getDestinationGas(uint256 chainId) external view returns (uint128);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint128 |
getDestinationMsgValue
function getDestinationMsgValue(uint256 chainId) external view returns (uint128);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| recipient | bytes | |
| payload | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
registerEid
Registers an EVM chainId ↔ LayerZero eid equivalence (both directions). Admin only.
function registerEid(uint256 chainId, uint32 eid) external;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| eid | uint32 |
registerPeer
Registers a trusted 32-byte peer (remote adapter) for a chain. Admin only.
function registerPeer(uint256 chainId, bytes32 peer) external;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| peer | bytes32 |
configureDestination
Configures a destination's executor lzReceive gas and native msg.value. Admin only.
function configureDestination(uint256 chainId, uint128 gas, uint128 msgValue) external;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| gas | uint128 | |
| msgValue | uint128 |
Events
RegisteredEid
Emitted when an EVM chainId ↔ LayerZero eid equivalence is registered.
event RegisteredEid(uint256 indexed chainId, uint32 eid);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| eid | uint32 |
RegisteredPeer
Emitted when a trusted 32-byte peer (remote adapter) is registered for a chain.
event RegisteredPeer(uint256 indexed chainId, bytes32 peer);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| peer | bytes32 |
ConfiguredDestination
Emitted when a destination's executor lzReceive gas / native msg.value is configured.
event ConfiguredDestination(uint256 indexed chainId, uint128 gas, uint128 msgValue);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| gas | uint128 | |
| msgValue | uint128 |
Errors
EidAlreadyRegistered
An eid equivalence is already registered for this chainId or eid.
error EidAlreadyRegistered(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
PeerAlreadyRegistered
A peer is already registered for this chain.
error PeerAlreadyRegistered(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
UnknownDestinationChain
The destination chain has no eid and/or no peer registered.
error UnknownDestinationChain(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
DestinationNotConfigured
The destination chain has no executor gas configured (call configureDestination).
error DestinationNotConfigured(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
InsufficientFee
The native value supplied was below the quoted LayerZero native fee.
error InsufficientFee(uint256 provided, uint256 required);Parameters
| Name | Type | Description |
|---|---|---|
| provided | uint256 | |
| required | uint256 |
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
| Name | Type | Description |
|---|---|---|
| caller | address |
InvalidOriginGateway
The inbound source did not match the registered peer for its chain.
error InvalidOriginGateway(uint32 srcEid, bytes32 sender);Parameters
| Name | Type | Description |
|---|---|---|
| srcEid | uint32 | |
| sender | bytes32 |
MessageAlreadyExecuted
The inbound message (chainId, LayerZero guid) was already delivered (replay).
error MessageAlreadyExecuted(uint256 chainId, bytes32 guid);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| guid | 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 peer misdirecting delivery).
error WrongDestinationChain(uint256 chainId);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |