- Complete send workflow (quote, approve, send, endpoint processing)
- DVN verification process and verification status checks
- Executor delivery and OApp receive handling
- Recovery operations (skip, clear, nilify, burn)
- Security considerations for payload hashes and reentrancy
This page documents the complete message lifecycle with contract-level implementation details:
- Send Workflow: Message initiation, fee calculation, nonce management, and packet dispatch
- Verification Workflow: DVN submission, verification checks, and execution readiness
- Receive Workflow: Executor delivery, payload clearing, and OApp processing
Send Overview
When an OApp initiates a crosschain message, the following high-level steps occur on the source chain.Message Lifecycle Overview
The LayerZero protocol enables secure crosschain messaging through a three-phase process:Core Data Structures
Packet
ThePacket structure represents a crosschain message:
Origin
TheOrigin structure identifies the source of an incoming message:
MessagingParams
Parameters for sending a message:MessagingFee
Fee structure returned by quote operations:Send Workflow
When an OApp initiates a crosschain message, the following steps occur:Step 1: Quote the Fee
Before sending, get a fee estimate:Step 2: Approve Fees
The caller must approve the Endpoint to spend their tokens:Step 3: Send the Message
The OApp calls the Endpoint’ssend function:
Step 4: Endpoint Processing
The Endpoint performs the following:- Creates the Packet with a unique GUID and incremented nonce
- Looks up the Send Library for this OApp/destination pair
- Routes to Message Library (ULN302) for worker fee calculation
- Pays Workers (DVNs, Executor) via ERC20 transfers
- Emits PacketSent event with encoded packet and options
Events Emitted During Send
| Event | Description |
|---|---|
PacketSent | Contains encoded packet, options, and send library address |
Verification Workflow
After aPacketSent event is emitted, DVNs verify the message and the destination Endpoint records verification data.
DVN Verification Process
Step 1: DVN Monitors Source Chain
DVNs monitor the source chain forPacketSent events and extract the packet data.
Step 2: DVN Submits Verification
Once a DVN has verified the packet (e.g., confirmed finality), it submits the verification to the receive library. The receive library then callsverify on the destination Endpoint.
Step 3: Check Verification Status
The Executor (or anyone) can check if a message is ready for execution:Events Emitted During Verification
| Event | Description |
|---|---|
PacketVerified | Contains origin, receiver, and payload hash |
Receive Workflow
Once verified, the Executor delivers the message to the destination OApp.Executor Delivery
Step 1: Executor Calls lz_receive
Step 2: OApp Handles the Message
Your OApp implements theILayerZeroReceiver interface:
Events Emitted During Receive
| Event | Description |
|---|---|
PacketDelivered | Confirms successful delivery to receiver |
LzReceiveAlert | Emitted if lz_receive execution fails |
Recovery Operations
LayerZero provides mechanisms for handling stuck or problematic messages:Skip
Skip an unverified message (before DVN verification):Clear
Clear a verified but unexecuted message:Nilify
Reset a verification to allow re-verification:Burn
Permanently block a message:| Operation | Reversible | When to Use |
|---|---|---|
skip | Yes | Message won’t be verified |
clear | No | Unblock message ordering |
nilify | Yes | Dispute verification |
burn | No | Permanently reject message |
Security Considerations
Payload Hash Verification
The Endpoint stores only the hash of the payload, not the full message. This:- Saves storage costs
- Prevents spam attacks
- Requires Executor to provide correct message data
Reentrancy Protection
The Endpoint uses OpenZeppelin’sReentrancyGuard component:
Clear Before Execute
Thelz_receive function clears the payload hash before calling the receiver’s handler:
Next Steps
- Technical Overview - Starknet architecture details
- OApp Overview - Building custom OApps
- OFT Overview - Token transfer patterns
- Configuration Guide - DVN and Executor setup