Skip to main content
Test LayerZero contracts directly from your browser. No coding required. Explore key application functions for message fee calculation, sending, receiving, configuration, and state management. This page focuses on methods relevant to building applications and does not include worker-related functions.

Real Onchain Methods

All functions shown in this playground are real methods available in the LayerZero contracts today:We only document OApp-relevant instructions, excluding admin-only functions. State variables are clearly marked as direct account data reads, not instructions.

LayerZero EndpointV2

The main entry point for all crosschain messaging operations. This contract handles message routing, fee calculation, and configuration management.

Message Routing

Core functions for sending and receiving messages between smart contracts.

quote() - Get Fee Estimates

send() - Send Messages

lzReceive() - Receive Messages

sendCompose() - Send Compose Messages

lzCompose() - Execute Compose Messages

Configuration Management

Functions for setting custom verification, execution, and pathway management.

eid() - Get Endpoint ID

isRegisteredLibrary() - Check Library Registration

receiveLibraryTimeout() - Get Library Timeout

setDelegate() - Set Delegate Address

setSendLibrary() - Configure Send Library

setReceiveLibrary() - Configure Receive Library

setConfig() - Set Configuration Parameters

Message Recovery & Security

Functions for handling message exceptions, security threats, and recovery scenarios.

clear() - Clear Stored Message

burn() - Permanently Block Message

skip() - Skip Message Nonce

nilify() - Mark Message as Nil

Status Checks

Functions for querying current configuration settings, library assignments, nonce tracking, and message states.

getConfig() - Check Configuration

delegates() - Check Delegate Address

getSendLibrary() - Get Send Library

getReceiveLibrary() - Get Receive Library

inboundNonce() - Get Processed Nonce

lazyInboundNonce() - Get Lazy Nonce

initializable() - Check Message Initialization

verifiable() - Check Message Verification

inboundPayloadHash() - Get Message Payload Hash

nextGuid() - Get Next Message GUID

composeQueue() - Check Compose Message Queue

isSendingMessage() - Check Send State

getSendContext() - Get Current Send Context

Events

Key events emitted by the EndpointV2 contract.

PacketSent - Message Sent Event

PacketVerified - Message Verified Event

PacketDelivered - Message Delivered Event

ComposeSent - Compose Message Queued Event

ComposeDelivered - Compose Message Delivered Event

DelegateSet - Delegate Configuration Event

SendLibrarySet - Send Library Configuration Event

ReceiveLibrarySet - Receive Library Configuration Event

ReceiveLibraryTimeoutSet - Library Timeout Configuration Event

InboundNonceSkipped - Nonce Skip Event

PacketNilified - Message Nilified Event

PacketBurnt - Message Burnt Event

Errors

LZ_InsufficientFee - Insufficient Fee

LZ_InvalidNonce - Invalid Nonce

LZ_Unauthorized - Unauthorized Access

LZ_SendReentrancy - Send Reentrancy Detected

Key Functions to Try:

  • Messaging Operations:
    • quote() - Get fee estimates for crosschain messages
    • send() - Send messages to other chains
    • lzReceive() - Receive messages from other chains
    • sendCompose() - Queue compose messages
    • lzCompose() - Execute compose messages
  • Configuration Management:
    • setDelegate() - Assign configuration permissions
    • setSendLibrary() - Choose send message library
    • setReceiveLibrary() - Choose receive message library
    • setConfig() - Set library-specific parameters
  • Message Recovery & Security:
    • burn() - Permanently block malicious messages
    • skip() - Skip flagged message nonces
    • nilify() - Mark messages for re-verification
    • clear() - Clear verified but unexecuted messages
  • Status Checks:
    • getConfig() - Check current configurations
    • delegates() - View current delegate address
    • getSendLibrary() - Check send library for endpoint
    • getReceiveLibrary() - Check receive library for endpoint
    • inboundNonce() - Get highest processed message nonce
    • lazyInboundNonce() - Get highest verified/skipped nonce
    • nextGuid() - Get next message GUID
    • composeQueue() - Check compose queue
    • isSendingMessage() - Check send state
    • getSendContext() - Get send context

LayerZero Message Libraries

Message Libraries handle the core verification and execution logic for LayerZero messages. While developers don’t interact with these contracts directly, understanding their error codes and events is crucial for debugging failed transactions.

Current Message Libraries

  • SendUln302: Handles outbound message verification setup
  • ReceiveUln302: Processes inbound message verification and execution
  • ReadLib1002: Manages crosschain read operations
When You’ll See These: These errors appear when calling Endpoint methods like send() or lzReceive(). The Endpoint delegates to these libraries internally, so their errors bubble up through your Endpoint transactions.

SendUln302 - Outbound Message Library

The SendUln302 library manages the configuration and verification setup for outbound messages. It coordinates with DVNs (Decentralized Verifier Networks) and handles fee calculations for message transmission.

Errors

Configuration & Setup Errors

LZ_ULN_InvalidConfigType - Invalid Configuration Type

LZ_ULN_InvalidRequiredDVNCount - Invalid DVN Count

LZ_ULN_InvalidOptionalDVNCount - Invalid Optional DVN Count

LZ_ULN_InvalidOptionalDVNThreshold - Invalid DVN Threshold

LZ_ULN_AtLeastOneDVN - At Least One DVN Required

LZ_ULN_InvalidConfirmations - Invalid Confirmations

LZ_ULN_Unsorted - DVNs Not Sorted

Worker & Option Errors

LZ_ULN_InvalidWorkerId - Invalid Worker ID

LZ_ULN_InvalidWorkerOptions - Invalid Worker Options

LZ_ULN_UnsupportedOptionType - Unsupported Option Type

LZ_ULN_InvalidLegacyType1Option - Invalid Legacy Type 1 Option

LZ_ULN_InvalidLegacyType2Option - Invalid Legacy Type 2 Option

LZ_ULN_UnsupportedEid - Unsupported Endpoint ID

Fee & Payment Errors

LZ_MessageLib_InvalidAmount - Invalid Fee Amount

LZ_MessageLib_TransferFailed - Fee Transfer Failed

Library Access Errors

LZ_MessageLib_OnlyEndpoint - Only Endpoint Allowed

LZ_MessageLib_InvalidExecutor - Invalid Executor

LZ_MessageLib_NotTreasury - Not Treasury

LZ_MessageLib_CannotWithdrawAltToken - Cannot Withdraw Alt Token

Message Validation Errors

LZ_MessageLib_InvalidMessageSize - Message Too Large

LZ_MessageLib_ZeroMessageSize - Zero Message Size

DVN_InvalidDVNOptions - Invalid DVN Options

DVN_InvalidDVNIdx - Invalid DVN Index

Transfer Errors

Transfer_NativeFailed - Native Transfer Failed

Transfer_ToAddressIsZero - Transfer to Zero Address

Events

DVNFeePaid - DVN Fee Payment

ReceiveUln302 - Inbound Message Library

The ReceiveUln302 library handles the verification and execution of inbound messages. It validates DVN signatures, manages message ordering, and ensures secure message delivery.

Errors

Verification Errors

LZ_ULN_InvalidPacketHeader - Invalid Packet Header

LZ_ULN_InvalidPacketVersion - Wrong Packet Version

LZ_ULN_InvalidEid - Invalid Endpoint ID

Configuration Errors

LZ_ULN_InvalidConfigType - Invalid Configuration Type

LZ_ULN_InvalidRequiredDVNCount - Invalid DVN Count

LZ_ULN_InvalidOptionalDVNCount - Invalid Optional DVN Count

LZ_ULN_InvalidOptionalDVNThreshold - Invalid DVN Threshold

LZ_ULN_AtLeastOneDVN - At Least One DVN Required

LZ_ULN_InvalidConfirmations - Invalid Confirmations

LZ_ULN_Unsorted - DVNs Not Sorted

LZ_ULN_UnsupportedEid - Unsupported Endpoint ID

LZ_ULN_Verifying - Already Verifying

LZ_MessageLib_OnlyEndpoint - Only Endpoint Allowed

ReadLib1002 - Crosschain Read Library

The ReadLib1002 library enables crosschain data reading without state changes. It manages read channels, handles request/response cycles, and ensures data integrity.

Errors

Configuration Errors

LZ_RL_InvalidConfigType - Invalid Configuration Type

LZ_RL_InvalidRequiredDVNCount - Invalid DVN Count

LZ_RL_InvalidOptionalDVNCount - Invalid Optional DVN Count

LZ_RL_InvalidOptionalDVNThreshold - Invalid DVN Threshold

Validation Errors

LZ_RL_InvalidPacketHeader - Invalid Packet Header

LZ_RL_InvalidPacketVersion - Wrong Packet Version

LZ_RL_InvalidCmdHash - Invalid Command Hash

LZ_RL_InvalidReceiver - Invalid Receiver

LZ_RL_InvalidAmount - Invalid Fee Amount

LZ_RL_Verifying - Already Verifying

LZ_RL_InvalidEid - Invalid Endpoint ID

LZ_RL_AtLeastOneDVN - At Least One DVN Required

LZ_RL_Unsorted - DVNs Not Sorted

LZ_RL_UnsupportedEid - Unsupported Endpoint ID

Library Access Errors

LZ_MessageLib_OnlyEndpoint - Only Endpoint Allowed

LZ_RL_InvalidExecutor - Invalid Executor

LZ_RL_NotTreasury - Not Treasury

LZ_RL_CannotWithdrawAltToken - Cannot Withdraw Alt Token

Worker & Option Errors

LZ_ULN_InvalidWorkerId - Invalid Worker ID

LZ_ULN_InvalidWorkerOptions - Invalid Worker Options

LZ_ULN_UnsupportedOptionType - Unsupported Option Type

LZ_ULN_InvalidLegacyType1Option - Invalid Legacy Type 1 Option

LZ_ULN_InvalidLegacyType2Option - Invalid Legacy Type 2 Option

DVN Errors

DVN_InvalidDVNOptions - Invalid DVN Options

DVN_InvalidDVNIdx - Invalid DVN Index

Transfer Errors

Transfer_NativeFailed - Native Transfer Failed

Transfer_ToAddressIsZero - Transfer to Zero Address

Troubleshooting Common Library Errors

  • LZ_MessageLib_InvalidAmount: Always use quote() before send() to get exact fees
  • LZ_MessageLib_TransferFailed: Ensure contract has sufficient ETH balance
  • LZ_RL_InvalidAmount: Ensure correct fee for read operations
  • DVN_InvalidDVNOptions: Check DVN option encoding and parameters

Configuration Issues

  • LZ_ULN_InvalidRequiredDVNCount: Must have at least 1 required DVN
  • LZ_ULN_InvalidOptionalDVNThreshold: Threshold must be ≤ optional DVN count
  • LZ_ULN_InvalidConfigType: Use correct config type (ULN=2, Executor=1)
  • LZ_RL_InvalidConfigType: Use correct config type for read library

Verification Issues

  • LZ_ULN_Verifying: Message already being verified, wait for completion
  • LZ_RL_Verifying: Read response already being verified
  • LZ_ULN_InvalidPacketHeader: Possible message corruption or tampering
  • LZ_RL_InvalidPacketHeader: Read packet header malformed
  • LZ_ULN_InvalidPacketVersion: Wrong packet version for message library
  • LZ_RL_InvalidPacketVersion: Wrong packet version for read library
For detailed troubleshooting guides, see LayerZero Troubleshooting.

Omnichain Application (OApp)

The foundation for building any crosschain application. OApp provides the core messaging infrastructure for a smart contract interacting with the EndpointV2.

Core Information

oAppVersion() - Get OApp Version

endpoint() - Get Endpoint Address

Peer Configuration

peers() - Get Remote Peer Address

setPeer() - Connect Remote Chains

setDelegate() - Set Configuration Delegate

Message Reception

allowInitializePath() - Check Path Initialization

nextNonce() - Get Next Message Nonce

lzReceive() - Receive Crosschain Messages

Composability

isComposeMsgSender() - Verify Compose Sender

Events and Errors

Key events and errors emitted by the OApp contract.

Events

PeerSet - Peer Configuration Updated

Errors

OnlyPeer - Unauthorized Peer Message

NoPeer - Missing Peer Configuration

InvalidEndpointCall - Invalid Endpoint Call

InvalidDelegate - Invalid Delegate Configuration

NotEnoughNative - Insufficient Native Fee

OnlyEndpoint - Unauthorized Endpoint Call

LzTokenUnavailable - LayerZero Token Not Available

Key Functions to Try:

  • Core Information:
    • oAppVersion() - Get OApp version information
    • endpoint() - Get connected endpoint address
  • Peer Configuration:
    • setPeer() - Connect to remote chains
    • peers() - Check connected chains
    • setDelegate() - Set configuration delegate
  • Message Reception:
    • lzReceive() - Receive crosschain messages
    • allowInitializePath() - Check path initialization
    • nextNonce() - Get message ordering info
  • Composability:
    • isComposeMsgSender() - Verify compose sender

Tips:

  • Peers must be set before messaging
  • Nonces ensure ordered delivery
  • Options control execution parameters

Omnichain Application Read (OAppRead)

OAppRead extends the standard OApp with LayerZero Read functionality, enabling crosschain data reading capabilities. It includes all standard methods plus the read channel configuration.

setReadChannel() - Configure Read Channel

Key Functions to Try:

  • setReadChannel() - Configure read channel for crosschain data reading
  • Plus all standard OApp functions listed above

Omnichain Fungible Token (OFT)

OFT inherits from OApp, providing all crosschain messaging capabilities plus token-specific functionality. Create tokens that work seamlessly across multiple blockchains while maintaining a unified supply.

Send Tokens

quoteSend() - Get Transfer Fees

quoteOFT() - Get Detailed Transfer Quote

send() - Transfer Tokens

Token Details

sharedDecimals() - Get Shared Decimals

approvalRequired() - Check Approval Requirement

oftVersion() - Get OFT Version

token() - Get Underlying Token Address

decimalConversionRate() - Get Decimal Conversion Factor

Management Functions

owner() - Get Current Owner

transferOwnership() - Transfer Contract Ownership

renounceOwnership() - Renounce Ownership

setPeer() - Connect to Remote OFTs

setEnforcedOptions() - Configure Message Options

setMsgInspector() - Set Message Inspector

Events

Key events emitted by the OFT contract.

OFTSent - Token Transfer Sent

OFTReceived - Token Transfer Received

Transfer - Standard ERC20 Transfer

Errors

InvalidLocalDecimals - Invalid Decimal Configuration

SlippageExceeded - Transfer Slippage Too High

AmountSDOverflowed - Shared Decimal Overflow

Key Functions to Try:

  • Transfer Operations:
    • quoteSend() - Get transfer fee estimates
    • send() - Transfer tokens crosschain
    • quoteOFT() - Get comprehensive transfer quotes
  • Token Information:
    • sharedDecimals() - Check decimal configuration
    • approvalRequired() - Check if approval is needed
    • oftVersion() - Get OFT implementation version
    • token() - Get underlying token address
    • decimalConversionRate() - Get decimal conversion factor
  • Management Functions:
    • owner() - Check current contract owner
    • setPeer() - Connect to OFTs on other chains
    • setEnforcedOptions() - Configure security parameters
    • setMsgInspector() - Set message inspector
    • transferOwnership() - Transfer contract ownership
    • renounceOwnership() - Permanently remove ownership

Tips:

  • Always call quoteSend() before send() to get accurate fees
  • The minAmountLD parameter provides slippage protection
  • Shared decimals (typically 6-8) may differ from local decimals (e.g., 18 for most ERC20s)
  • approvalRequired() returns false for OFT and true for OFTAdapter
  • Use quoteOFT() for detailed information including transfer limits and fee breakdowns
  • OFTAdapter requires approval on the underlying token before sending
  • Must call setPeer() to connect OFTs on different chains before transfers
  • Only the contract owner can call management functions
  • Use setEnforcedOptions() to enforce minimum gas limits for security
  • renounceOwnership() is irreversible - use with extreme caution
For complete contract documentation including all functions, events, and technical details:

Decentralized Verifier Network (DVN)

DVNs provide independent verification of crosschain messages. Each DVN can set custom pricing and confirmation requirements for different destination chains.

getFee() - Get DVN Verification Fee

InteractiveDVN temporarily disabled.

dstConfig() - Get DVN Configuration

InteractiveDVN temporarily disabled.

Executor

Executors handle the final delivery of verified messages on destination chains. They manage gas pricing, execution parameters, and delivery guarantees.

getFee() - Get Execution Fee

dstConfig() - Get Destination Configuration

Contract ABIs shown here are from the latest deployment. Always verify addresses and ABIs for your specific use case.