Skip to main content
LayerZero offers both unordered delivery and ordered delivery, providing developers with the flexibility to choose the most appropriate transaction ordering mechanism based on the specific requirements of their application.

Unordered Delivery

By default, the LayerZero protocol uses unordered delivery, where transactions can be executed out of order if all transactions prior have been verified. If transactions 1 and 2 have not been verified, then transaction 3 cannot be executed until the previous nonces have been verified. Once nonces 1, 2, 3 have been verified:
  • If nonce 2 failed to execute (due to some gas or user logic related issue), nonce 3 can still proceed and execute.
Diagram showing unordered (lazy) nonce enforcement: even if nonce 2 fails to execute, nonce 3 can still proceed after verification, demonstrating flexible out-of-order execution This is particularly useful in scenarios where transactions are not critically dependent on the execution of previous transactions.

Ordered Delivery

Developers can configure the OApp contract to use ordered delivery. Diagram showing ordered (strict) nonce enforcement: packets with nonces 1, 2, 3 must be executed in exact sequential order for system consistency In this configuration, if you have a sequence of packets with nonces 1, 2, 3, and so on, each packet must be executed in that exact, sequential order:
  • If nonce 2 fails for any reason, it will block all subsequent transactions with higher nonces from being executed until nonce 2 is resolved.
Diagram showing strict nonce enforcement failure scenario: if nonce 2 fails, all subsequent transactions with higher nonces are blocked until nonce 2 is resolved Strict nonce enforcement can be important in scenarios where the order of transactions is critical to the integrity of the system, such as any multi-step process that needs to occur in a specific sequence to maintain consistency.
In these cases, strict nonce enforcement can be used to provide consistency, fairness, and censorship-resistance to maintain system integrity.

Enabling Ordered Delivery

To implement strict nonce enforcement, you need to implement the following:
  • a mapping to track the maximum received nonce.
  • override _acceptNonce and nextNonce.
  • add ExecutorOrderedExecutionOption in _options when calling _lzSend.
  • a governance function to keep the nonce mapping between the protocol and application in sync when skipping nonces.
If you do not pass an ExecutorOrderedExecutionOption in your _lzSend call, the Executor will attempt to execute the message despite your application-level nonce enforcement, leading to a message revert.
Append to your Message Options an ExecutorOrderedExecutionOption in your _lzSend call:

Keeping Nonces In Sync

When skipping nonces at the protocol level, such as calling endpoint.skip, your OApp’s local mapping must be incremented as well. If the local receivedNonce mapping falls behind the protocol’s stored nonce, subsequent messages will revert with an invalid nonce error. A governance helper could look like:
Keeping these values aligned ensures nextNonce returns the correct value and prevents ordered messages from being blocked. Implement strict nonce enforcement via function override: