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 messagessend()- Send messages to other chainslzReceive()- Receive messages from other chainssendCompose()- Queue compose messageslzCompose()- Execute compose messages
- Configuration Management:
setDelegate()- Assign configuration permissionssetSendLibrary()- Choose send message librarysetReceiveLibrary()- Choose receive message librarysetConfig()- Set library-specific parameters
- Message Recovery & Security:
burn()- Permanently block malicious messagesskip()- Skip flagged message noncesnilify()- Mark messages for re-verificationclear()- Clear verified but unexecuted messages
- Status Checks:
getConfig()- Check current configurationsdelegates()- View current delegate addressgetSendLibrary()- Check send library for endpointgetReceiveLibrary()- Check receive library for endpointinboundNonce()- Get highest processed message noncelazyInboundNonce()- Get highest verified/skipped noncenextGuid()- Get next message GUIDcomposeQueue()- Check compose queueisSendingMessage()- Check send stategetSendContext()- 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 likesend()orlzReceive(). 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 ErrorsLZ_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 ErrorsLZ_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 ErrorsLZ_MessageLib_InvalidAmount - Invalid Fee Amount
LZ_MessageLib_TransferFailed - Fee Transfer Failed
Library Access ErrorsLZ_MessageLib_OnlyEndpoint - Only Endpoint Allowed
LZ_MessageLib_InvalidExecutor - Invalid Executor
LZ_MessageLib_NotTreasury - Not Treasury
LZ_MessageLib_CannotWithdrawAltToken - Cannot Withdraw Alt Token
Message Validation ErrorsLZ_MessageLib_InvalidMessageSize - Message Too Large
LZ_MessageLib_ZeroMessageSize - Zero Message Size
DVN_InvalidDVNOptions - Invalid DVN Options
DVN_InvalidDVNIdx - Invalid DVN Index
Transfer ErrorsTransfer_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 ErrorsLZ_ULN_InvalidPacketHeader - Invalid Packet Header
LZ_ULN_InvalidPacketVersion - Wrong Packet Version
LZ_ULN_InvalidEid - Invalid Endpoint ID
Configuration ErrorsLZ_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 ErrorsLZ_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 ErrorsLZ_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 ErrorsLZ_MessageLib_OnlyEndpoint - Only Endpoint Allowed
LZ_RL_InvalidExecutor - Invalid Executor
LZ_RL_NotTreasury - Not Treasury
LZ_RL_CannotWithdrawAltToken - Cannot Withdraw Alt Token
Worker & Option ErrorsLZ_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 ErrorsDVN_InvalidDVNOptions - Invalid DVN Options
DVN_InvalidDVNIdx - Invalid DVN Index
Transfer ErrorsTransfer_NativeFailed - Native Transfer Failed
Transfer_ToAddressIsZero - Transfer to Zero Address
Troubleshooting Common Library Errors
Fee-Related Issues
- LZ_MessageLib_InvalidAmount: Always use
quote()beforesend()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
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 informationendpoint()- Get connected endpoint address
- Peer Configuration:
setPeer()- Connect to remote chainspeers()- Check connected chainssetDelegate()- Set configuration delegate
- Message Reception:
lzReceive()- Receive crosschain messagesallowInitializePath()- Check path initializationnextNonce()- 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 estimatessend()- Transfer tokens crosschainquoteOFT()- Get comprehensive transfer quotes
- Token Information:
sharedDecimals()- Check decimal configurationapprovalRequired()- Check if approval is neededoftVersion()- Get OFT implementation versiontoken()- Get underlying token addressdecimalConversionRate()- Get decimal conversion factor
- Management Functions:
owner()- Check current contract ownersetPeer()- Connect to OFTs on other chainssetEnforcedOptions()- Configure security parameterssetMsgInspector()- Set message inspectortransferOwnership()- Transfer contract ownershiprenounceOwnership()- Permanently remove ownership
Tips:
- Always call
quoteSend()beforesend()to get accurate fees - The
minAmountLDparameter 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
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.