This document contains a high level overview of how to implement and integrate a basic third party Executor into the LayerZero V2 protocol.Documentation Index
Fetch the complete documentation index at: https://docs.layerzero.network/llms.txt
Use this file to discover all available pages before exploring further.
Fee Quoting, Collection, and Withdrawal
Executors should implement and deploy an Executor contract on every chain they want to support. The contract must implement theILayerZeroExecutor interface, which specifies two functions: assignJob and getFee.
| Function Name | Type | Description |
|---|---|---|
assignJob | Payable | Called as part of _lzSend. |
getFee | View | Typically called by applications before sending the packet to estimate fees. |
assignJob function.
Building an Executor
The Executor is divided into two off-chain workflows: the Committer and the Executor.Committer
- The Committer role first listens for the
PacketSentevent:
- After the
PacketSentevent, theExecutorFeePaidis how you know your Executor has been assigned to commit and execute the packet.
- After receiving the fee, your Executor should listen for the
PacketVerifiedevent, signaling that the packet can now be committed to the destination messaging channel.
- After listening for the previous events, your Executor should perform an idempotency check by calling Ultra Light Node 301 and Ultra Light Node 302:
Verifying, your Executor must wait for more DVNs to sign the packet’s payloadHash. After a DVN signs the payloadHash, it will emit PayloadVerified.
Verifiable, then your Executor must call commitVerification:
Verified, the commit has already occurred and the commit workflow can be terminated.
Executor
- The Executor role first listens for the
PacketSentevent:
- After the
PacketSentevent, theExecutorFeePaidis how you know your Executor has been assigned to commit and execute the packet.
-
After receiving the fee, your Executor should listen for the
PacketVerifiedevent, signaling that the packet can now be executed. - After listening for the previous events, your Executor should perform an idempotency check:
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:
Executed, your Executor has fulfilled its obligation, and you can terminate the Executor workflow.