Skip to main content
This document contains a high level overview of how to implement and integrate a basic third party Executor into the LayerZero V2 protocol.

Fee Quoting, Collection, and Withdrawal

Executors should implement and deploy an Executor contract on every chain they want to support. The contract must implement the ILayerZeroExecutor interface, which specifies two functions: assignJob and getFee.
If your Executor is responsible for a packet, the LayerZero Endpoint will call your Executor contract’s assignJob function.

Building an Executor

The Executor is divided into two off-chain workflows: the Committer and the Executor.

Committer

  1. The Committer role first listens for the PacketSent event:
  1. After the PacketSent event, the ExecutorFeePaid is how you know your Executor has been assigned to commit and execute the packet.
  1. After receiving the fee, your Executor should listen for the PacketVerified event, signaling that the packet can now be committed to the destination messaging channel.
  1. After listening for the previous events, your Executor should perform an idempotency check by calling Ultra Light Node 301 and Ultra Light Node 302:
This function will return the following possible states:
If the state is Verifying, your Executor must wait for more DVNs to sign the packet’s payloadHash. After a DVN signs the payloadHash, it will emit PayloadVerified.
Your Executor only needs to perform subsequent checks of VerificationState when it hears PayloadVerified on the destination chain.
If the state is Verifiable, then your Executor must call commitVerification:
If the state is Verified, the commit has already occurred and the commit workflow can be terminated.
To know your workflow is finished, your Executor should perform an idempotency check at the end of the commit workflow.

Executor

  1. The Executor role first listens for the PacketSent event:
  1. After the PacketSent event, the ExecutorFeePaid is how you know your Executor has been assigned to commit and execute the packet.
  1. After receiving the fee, your Executor should listen for the PacketVerified event, signaling that the packet can now be executed.
  2. After listening for the previous events, your Executor should perform an idempotency check:
This function will return the following possible states:
If the state is NotExecutable, your Executor must wait for the committer to commit the message packet, or you may have to wait for some previous nonces. If the state is Executable, your Executor should decode the packet’s options using the options.ts package and call the Endpoint’s lzReceive function with the packet information:
To know your workflow is finished, your Executor should perform an idempotency check at the end of the execute workflow.
If the state is Executed, your Executor has fulfilled its obligation, and you can terminate the Executor workflow.

Mock Executor

Both Paladin Blockchain Security and Lazer Technologies have built an implementation and open-sourced the codebase for anyone interested in reviewing a sample Executor implementation.
These codebases are not owned by LayerZero. Exercise caution when interacting with any third party contracts or sample materials.