Skip to main content
Version: Endpoint V2

What is LayerZero V2?

LayerZero is a messaging protocol, not a blockchain. Using smart contracts deployed on each chain, in combination with Decentralized Verifier Networks (DVNs) and Executors, LayerZero enables different blockchains to seamlessly interact with one another.

Protocol V2 Light Protocol V2 Dark

In LayerZero V2, message verification and execution have been separated into two distinct phases, providing developers with more control over their application's security configuration and independent execution.

Combined with improved handling, message throughput, programmability, and other contract specific improvements, LayerZero V2 provides a more flexible, performant, and future-proof messaging protocol.

Start reading more about this design in the Protocol Overview.

New Security & Execution

LayerZero V2 offers direct improvements for both existing, deployed applications on Endpoint V1, as well as new features that enhance the creation and scalability of omnichain applications deployed on the new Endpoint V2.

Applications deployed on Endpoint V1 can receive two main overhauls to application security and execution by migrating their application's Message Library to Ultra Light Node 301. See the Migration Guide to learn more.

X of Y of N Message Authentication

The new Ultra Light Node 301 (V1) and Ultra Light Node 302 (V2) allow application owners to configure a custom Security Stack, choosing a set of different Decentralized Verifier Networks (DVNs) to verify the payload hash on the destination MessageLib. A subset of these DVNs are all required (X) to verify the payload hash, and a threshold (Y) of a set of optional DVNs (N) must also verify the same payload hash before the packet can be delivered.

OApp owners can now utilize multiple verification models to achieve a desired security and cost-efficiency outcome based on their application's needs.

You can select between the following DVNs at launch, or permissionlessly Build DVNs

Security Stack (DVNs) can be found here.

Independent Message Execution

In LayerZero V1, the Relayer handled both the verification and execution of messages:

  • Oracle: Handled the verification of message block headers.

  • Relayer: Handled the verification of tx-proofs and the execution of messages.

In LayerZero V2, the verification of messages is now handled by the Security Stack, and execution by Executors:

  • Security Stack: your application's selected (X of Y of N) DVNs.

  • Executor (Optional): your application's selected automated caller for receiving messages.

For new applications deployed on Endpoint V2, this caller is completely permissionless.

New Protocol Contracts

In addition to New Message Libraries, LayerZero V2 includes improvements to the core protocol architecture.

Developers can take advantage of higher message throughput on certain blockchains, improved programmability, smaller contract sizes, and more by deploying applications using the Endpoint V2 Contract Standards.

Improved Message Handling

Because the V2 protocol splits the verification and execution of messages, message nonces can now be executed out of order while still maintaining censorship resistance:

  • Verified: the nonce of the Message Packet has successfully been verified, and awaits execution.

  • Delivered: the message has successfully been executed and received by the destination application.

In V1, by default, if a sent message failed to execute on destination, the relevant pathway would be blocked by a storedPayload event that would temporarily stop all subsequent messages from being executed.

Now by default, the subsequent flow of messages will continue to be delivered and executed even if a previous message failed to execute.

Ordered execution can still be enabled at the application level by configuring Ordered Message Delivery.

Higher Message Throughput

This Unordered Message Delivery offers the highest possible message throughput (i.e., the chain itself), by using improved on-chain nonce tracking via a Lazy Inbound Nonce and Inbound Nonce as pointers for where to try message execution.

  • Lazy Inbound Nonce: the highest executed message nonce in the system.

  • Inbound Nonce: the latest verified message nonce, where all preceding nonces have also been verified.

Since nonces must be verified before they can be executed, this system enables LayerZero V2 to verify and losslessly execute packets out-of-order, streamlining message execution without compromising censorship resistance.

Improved Programmability

LayerZero V2 has also significantly improved programmability in several ways:

  • Simplified Protocol Contract Interfaces: The improved contract interfaces in LayerZero V2 simplify message routing and handling, reducing the complexity involved in sending and receiving messages via the protocol. Developers can work more confidently and efficiently.

  • Path-Specific Libraries: Path-specific libraries in Endpoint V2 enable developers to configure different MessageLibs for specific pathways (source to destination), providing applications with more flexibility and customization.

  • Horizontal Composability: The new sendCompose and lzCompose interfaces, where external calls can be containerized into new message packets, allows applications to maintain a clear separation between the logic that handles the receipt of a message (lzReceive) and the logic of the external call itself (lzCompose). This ensures that each step is executed correctly and independently of others, enabling powerful cross-chain interactions.

Smaller Contract Sizes

LayerZero V2 introduces several improvements to enhance gas efficiency for developers and users interacting with LayerZero contracts. Let's break down these improvements:

  • Optimized Base Contracts: All LayerZero Contract Standards have been restructured to reduce the inherited gas cost from base contracts.

  • Compiler Efficiency: Improvements in the contracts lead to better compiler optimization, which in turn reduces the deployment and execution gas costs.

Chain Compatibility

V2 also significantly improves chain compatibility, further empowering developers to build versatile and efficient omnichain applications across a wider range of blockchains.

  • Chain-Agnostic Design: The protocol defines isolation between composed contract calls (composeSend to store data followed by lzCompose to compose the contract). This enables developers to build more uniform application designs across blockchains with different environment assumptions (e.g., lack of runtime dispatch). This is important for achieving broad compatibility with non-EVM chains and unifying the OApp interface across every chain.

  • Improved Gas Payment Options: The Endpoint can now specify an alternative gas token on a given chain during deployment. This flexibility accommodates blockchains that may have unique gas mechanisms or fee models.

  • Specific Library Defaults: Endpoints now support a different default library per chain pathway. This feature allows for more streamlined and efficient message processing that is tailored to the specific characteristics and unique requirements of each chain pair.

These improvements offer a more chain-agnostic approach to message handling, helping OApp developers design a single application architecture that can be unified across EVM and non-EVM chains.

Consistent Security Standards

  • Application Level Control: While application contracts can opt into pre-defined curated defaults, LayerZero gives you the choice to configure your application's settings for every pathway, offering unparalleled flexibility and security.

  • Immutable Core Contracts: LayerZero only uses immutable core contracts. This provides developers with a long-term stable and predictable interface to interact with, ensuring that security and reliability are never compromised by external updates.

  • Backwards Compatibility: LayerZero's on-chain message libraries are immutable and can never be removed or deprecated. LayerZero will always be backwards-compatible with previous MessageLib versions.

Get Started

LayerZero offers a fully integrated suite of Contract Standards to help you quickly build, launch, and scale your omnichain applications.

Start learning about LayerZero's architecture by either reading the Protocol Overview or the V2 Whitepaper.

Have questions? You can also ask for help or follow development in our Discord.