Skip to content
Lattice

ZetaChainGatewayAdapter

Git Source

Inherits: IERC7786GatewaySource, Callable, IZetaChainGatewayAdapter

Title: ZetaChainGatewayAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from ZetaChain (https://github.com/zeta-chain/protocol-contracts)

ERC-7786 cross-chain gateway facet over ZetaChain's GatewayEVM. sendMessage dispatches a message via the gateway to the destination's ZEVM universal app (the hub); onCall is the gateway's inbound delivery hook. EVM chains only. HUB-ROUTED — messages flow through a ZetaChain ZEVM universal app, not a direct peer.

Stateless delegator — logic/storage live in ZetaChainGatewayAdapterLib. The GatewayEVM is a DEPLOYED contract (address varies per connected chain), stored at init and mutable by an admin setter. The trusted-remote registry is a forward (chainId ⇒ app) + reverse (app ⇒ chainId) map of ZEVM universal apps; the gateway-gated onCall is the inbound analogue of CCIP's ccipReceive / LayerZero's lzReceive. Implements Callable (onCall) so the ZetaChain GatewayEVM can deliver inbound messages.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: ZetaChain

Functions

sendMessage

If any of the attributes is not supported, this function SHOULD revert with an

UnsupportedAttribute error. Other errors SHOULD revert with errors not specified in ERC-7786.

Endpoint for creating a new message. If the message requires further (gateway specific) processing before it can be sent to the destination chain, then a non-zero sendId must be returned. Otherwise, the message MUST be sent and this function must return 0.

function sendMessage(bytes calldata recipient, bytes calldata payload, bytes[] calldata attributes)
        external
        payable
        virtual
        returns (bytes32);

Parameters

NameTypeDescription
recipientbytes
payloadbytes
attributesbytes[]

Returns

NameTypeDescription
<none>bytes32

supportsAttribute

Getter to check whether an attribute is supported or not.

function supportsAttribute(bytes4 selector) external pure virtual returns (bool);

Parameters

NameTypeDescription
selectorbytes4

Returns

NameTypeDescription
<none>bool

onCall

Inbound delivery hook invoked by the GatewayEVM on message arrival.

function onCall(MessageContext calldata context, bytes calldata message)
        external
        payable
        virtual
        returns (bytes memory);

Parameters

NameTypeDescription
contextMessageContextThe ZetaChain message context (sender = the ZEVM universal app that originated the call).
messagebytesThe delivered message payload.

Returns

NameTypeDescription
<none>bytesThe receiver's result bytes (may be empty).

gateway

The ZetaChain GatewayEVM this adapter dispatches to / accepts onCall deliveries from.

function gateway() external view virtual returns (address);

Returns

NameTypeDescription
<none>address

getRemoteApp

The trusted remote ZEVM universal app (hub) registered for chainId (0 = unset).

function getRemoteApp(uint256 chainId) external view virtual returns (address);

Parameters

NameTypeDescription
chainIduint256

Returns

NameTypeDescription
<none>address

getChainIdForApp

The source chainId a trusted remote ZEVM universal app resolves to (0 = unset).

function getChainIdForApp(address remoteApp) external view virtual returns (uint256);

Parameters

NameTypeDescription
remoteAppaddress

Returns

NameTypeDescription
<none>uint256

defaultOnRevertGasLimit

The default onRevertGasLimit used to build per-message RevertOptions.

function defaultOnRevertGasLimit() external view virtual returns (uint256);

Returns

NameTypeDescription
<none>uint256

setGateway

Sets the ZetaChain GatewayEVM address. Rejects zero. Admin only.

function setGateway(address gateway_) external virtual;

Parameters

NameTypeDescription
gateway_address

registerRemote

Registers a trusted remote ZEVM universal app (hub) for a chain in BOTH maps. One-shot. Admin only.

function registerRemote(uint256 chainId, address remoteApp) external virtual;

Parameters

NameTypeDescription
chainIduint256
remoteAppaddress

setDefaultOnRevertGasLimit

Sets the default onRevertGasLimit used to build per-message RevertOptions. Admin only.

function setDefaultOnRevertGasLimit(uint256 onRevertGasLimit) external virtual;

Parameters

NameTypeDescription
onRevertGasLimituint256

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect ZetaChainGatewayAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: defaultOnRevertGasLimit() 0x6aff513e gateway() 0x116191b6 getChainIdForApp(address) 0xbe7acd1a getRemoteApp(uint256) 0xb4a6414c onCall((address),bytes) 0x676cc054 registerRemote(uint256,address) 0xb5efb8fd sendMessage(bytes,bytes,bytes[]) 0xcdfe7f5c setDefaultOnRevertGasLimit(uint256) 0x80f9c692 setGateway(address) 0x90646b4a supportsAttribute(bytes4) 0xdc680a0f

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes