Skip to main content

Overview

LayerZeroProver processes proof messages from LayerZero’s endpoint and records proven intents. It extends MessageBridgeProver to provide LayerZero V2-specific messaging functionality. Contract: contracts/prover/LayerZeroProver.sol Inheritance: ILayerZeroReceiver, MessageBridgeProver, Semver Proof Type: "LayerZero"
Domain ID vs Chain ID: LayerZero uses endpoint IDs (eids) that differ from chain IDs. Always consult LayerZero’s documentation to determine the correct endpoint ID for your target chain.

Constructor

Initializes the LayerZeroProver contract.
address
required
Address of the local LayerZero V2 endpoint contract
address
required
Address authorized to configure LayerZero settings (configs, paths, etc.)
address
required
Address of the Portal contract
bytes32[]
required
Array of trusted prover addresses (as bytes32 for cross-VM compatibility)
uint256
required
Minimum gas limit for cross-chain messages. Defaults to 200,000 if zero.
Behavior:
  • Sets delegate on the LayerZero endpoint for administrative functions
  • Delegate can configure settings on behalf of this contract
Errors:
  • EndpointCannotBeZeroAddress(): Endpoint address is zero
  • DelegateCannotBeZeroAddress(): Delegate address is zero
  • ZeroPortal(): Portal address is zero
Location: contracts/prover/LayerZeroProver.sol:57

State Variables

ENDPOINT

Address of the local LayerZero V2 endpoint contract.

PROOF_TYPE

Constant indicating this contract uses LayerZero for proving.

MIN_GAS_LIMIT

Minimum gas limit for cross-chain message dispatch. Inherited from MessageBridgeProver. Defaults to 200,000.

Core Functions

prove

Inherited from MessageBridgeProver. Initiates proving process by dispatching a message via LayerZero.
address
required
Address that initiated the proving request (receives refund if overpaid)
uint64
required
LayerZero endpoint ID (eid) of the source chain. NOT the chain ID.
bytes
required
Encoded (intentHash, claimant) pairs. Format: [intentHash1][claimant1][intentHash2][claimant2]...
bytes
required
ABI-encoded UnpackedData struct containing:
  • sourceChainProver (bytes32): Address of prover on source chain
  • options (bytes): LayerZero message options (empty for default)
  • gasLimit (uint256): Gas limit for execution (min 200k)
Behavior:
  1. Calculates required fee via fetchFee
  2. Validates msg.value covers fee
  3. Dispatches message via LayerZero endpoint
  4. Refunds excess payment to sender
Errors:
  • InsufficientFee(uint256 required): msg.value is less than required fee
  • DomainIdTooLarge(uint64 domainID): Domain ID exceeds uint32.max
Access Control: Only callable by PORTAL Location: Inherited from MessageBridgeProver.sol:112

lzReceive

Handles incoming LayerZero messages containing proof data. Called by the LayerZero endpoint.
Origin
required
Origin information containing:
  • srcEid (uint32): Source endpoint ID
  • sender (bytes32): Address that dispatched the message
  • nonce (uint64): Message nonce
bytes
required
Encoded message with format: [chainId (8 bytes)][intentHash1][claimant1][intentHash2][claimant2]...
Behavior:
  1. Validates sender is not zero
  2. Validates sender is whitelisted
  3. Extracts chain ID from first 8 bytes of message
  4. Processes intent proofs using _processIntentProofs
Errors:
  • MessageSenderCannotBeZeroAddress(): Sender is zero
  • UnauthorizedIncomingProof(bytes32 sender): Sender not whitelisted
Access Control: Only callable by ENDPOINT Location: contracts/prover/LayerZeroProver.sol:85

allowInitializePath

Checks if a path is allowed for receiving messages.
Origin
required
Origin information to check
Returns: true if sender is whitelisted, false otherwise Location: contracts/prover/LayerZeroProver.sol:105

nextNonce

Returns the next expected nonce from a source. Returns: Always returns 0 as this contract doesn’t track nonces Location: contracts/prover/LayerZeroProver.sol:117

fetchFee

Calculates the fee required for LayerZero message dispatch.
uint64
required
LayerZero endpoint ID of the source chain
bytes
required
Encoded (intentHash, claimant) pairs
bytes
required
ABI-encoded UnpackedData struct
Returns: Native fee amount required for message dispatch Note: Enforces minimum gas limit during unpacking. Location: contracts/prover/LayerZeroProver.sol:166

getProofType

Returns: "LayerZero"

Internal Functions

_dispatchMessage

Implementation of message dispatch for LayerZero. Called by base prove() function. Behavior:
  1. Unpacks data into structured format (enforces min gas limit)
  2. Formats LayerZero message parameters
  3. Calls ILayerZeroEndpointV2(ENDPOINT).send with fee
  4. Refund address is msg.sender
Location: contracts/prover/LayerZeroProver.sol:133

_formatLayerZeroMessage

Formats data for LayerZero message dispatch. Returns: MessagingParams struct with:
  • dstEid (uint32): Destination endpoint ID
  • receiver (bytes32): Source chain prover address
  • message (bytes): Encoded proofs
  • options (bytes): Gas options (uses provided or creates default with gas limit)
  • payInLzToken (bool): Always false (pay in native)
Default Options Format:
Location: contracts/prover/LayerZeroProver.sol:239

_unpackData

Decodes raw message data and enforces minimum gas limit. Behavior:
  • Decodes ABI-encoded UnpackedData
  • If gasLimit < MIN_GAS_LIMIT, sets to MIN_GAS_LIMIT
Location: contracts/prover/LayerZeroProver.sol:184

Data Structures

UnpackedData

Contains fields decoded from the data parameter. Gas limit is enforced to be at least MIN_GAS_LIMIT (200k).

Domain ID Mapping

LayerZero endpoint IDs (eids) are NOT chain IDs. You must use LayerZero-specific endpoint IDs.Examples:
  • Ethereum Mainnet: Endpoint 30101 (Chain ID 1)
  • Optimism: Endpoint 30111 (Chain ID 10)
  • Arbitrum: Endpoint 30110 (Chain ID 42161)
  • Base: Endpoint 30184 (Chain ID 8453)
Check LayerZero’s endpoint registry for the complete mapping.

Usage Example