EndpointV2
lzToken
delegates
constructor
_eid) to this instance, ensuring each chain has a distinct identifier for crosschain messaging.
Parameters
| Name | Type | Description |
|---|---|---|
| _eid | uint32 | the unique Endpoint Id for this deploy that all other Endpoints can use to send to it |
| _owner | address |
quote
_params. The fee quote takes into account the current messaging cost, which might vary over time. Note that the actual messaging cost could differ if the fees change between the quote and the message send operation.
MESSAGING STEP 0
Parameters
| Name | Type | Description |
|---|---|---|
| _params | struct MessagingParams | the messaging parameters |
| _sender | address | the sender of the message |
send
lzToken). If excess fees are supplied, the surplus is refunded to the provided _refundAddress.
MESSAGING STEP 1 - OApp need to transfer the fees to the endpoint before sending the message
Parameters
| Name | Type | Description |
|---|---|---|
| _params | struct MessagingParams | the messaging parameters |
| _refundAddress | address | the address to refund both the native and lzToken |
_send
Parameters
| Name | Type | Description |
|---|---|---|
| _sender | address | the address of the application sending the message to the destination chain |
| _params | struct MessagingParams | the messaging parameters |
verify
Parameters
| Name | Type | Description |
|---|---|---|
| _origin | struct Origin | a struct holding the srcEid, nonce, and sender of the message |
| _receiver | address | the receiver of the message |
| _payloadHash | bytes32 | the payload hash of the message |
lzReceive
extraData if needed for execution.
MESSAGING STEP 3 - the last step
execute a verified message to the designated receiver
the execution provides the execution context (caller, extraData) to the receiver. the receiver can optionally assert the caller and validate the untrusted extraData
cant reentrant because the payload is cleared before execution
Parameters
| Name | Type | Description |
|---|---|---|
| _origin | struct Origin | the origin of the message |
| _receiver | address | the receiver of the message |
| _guid | bytes32 | the guid of the message |
| _message | bytes | the message |
| _extraData | bytes | the extra data provided by the executor. this data is untrusted and should be validated. |
lzReceiveAlert
Parameters
| Name | Type | Description |
|---|---|---|
| _origin | struct Origin | the origin of the message |
| _receiver | address | the receiver of the message |
| _guid | bytes32 | the guid of the message |
| _gas | uint256 | |
| _value | uint256 | |
| _message | bytes | the message |
| _extraData | bytes | the extra data provided by the executor. |
| _reason | bytes | the reason for failure |
clear
_Oapp uses this interface to clear a message.
this is a PULL mode versus the PUSH mode of lzReceive
the cleared message can be ignored by the app (effectively burnt)
authenticated by oapp_
Parameters
| Name | Type | Description |
|---|---|---|
| _oapp | address | |
| _origin | struct Origin | the origin of the message |
| _guid | bytes32 | the guid of the message |
| _message | bytes | the message |
setLzToken
lzToken). This token may be used to pay for messaging fees. The function is designed to provide flexibility in case the initial configuration of the token was incorrect or needs to be updated. It should only be called by the contract owner.
Users should avoid approving non-LayerZero tokens to be spent by the EndpointV2 contract, as this function can override the token used for fees.
allows reconfiguration to recover from wrong configurations
users should never approve the EndpointV2 contract to spend their non-layerzero tokens
override this function if the endpoint is charging ERC20 tokens as native
only owner
Parameters
| Name | Type | Description |
|---|---|---|
| _lzToken | address | the new layer zero token address |
recoverToken
EndpointV2 contract. It supports both native tokens (if _token is set to 0x0) and ERC20 tokens. This ensures that tokens accidentally locked in the contract can be safely retrieved by the owner.
recover the token sent to this contract by mistake
only owner
Parameters
| Name | Type | Description |
|---|---|---|
| _token | address | the token to recover. if 0x0 then it is native token |
| _to | address | the address to send the token to |
| _amount | uint256 | the amount to send |
_payToken
_refundAddress.
handling token payments on endpoint. the sender must approve the endpoint to spend the token
internal function
Parameters
| Name | Type | Description |
|---|---|---|
| _token | address | the token to pay |
| _required | uint256 | the amount required |
| _supplied | uint256 | the amount supplied |
| _receiver | address | the receiver of the token |
| _refundAddress | address |
_payNative
_refundAddress. If the endpoint charges ERC20 tokens as native, this function can be overridden.
handling native token payments on endpoint
override this if the endpoint is charging ERC20 tokens as native
internal function
Parameters
| Name | Type | Description |
|---|---|---|
| _required | uint256 | the amount required |
| _supplied | uint256 | the amount supplied |
| _receiver | address | the receiver of the native token |
| _refundAddress | address | the address to refund the excess to |
_suppliedLzToken
lzToken) supplied for payment, but only if _payInLzToken is set to true. It checks the balance of the lzToken used to pay for the messaging fee.
get the balance of the lzToken as the supplied lzToken fee if payInLzToken is true
_suppliedNative
_assertMessagingFee
lzToken) are sufficient to cover the required messaging fees. If the supplied fees are insufficient, the function will assert an error.
Assert the required fees and the supplied fees are enough
nativeToken
0x0.
override this if the endpoint is charging ERC20 tokens as native
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | 0x0 if using native. otherwise the address of the native ERC20 token |
setDelegate
_initializable
lazyInboundNonce, which controls the message order and flow.
_verifiable
verifiable for the receiver. It ensures that the message payload is valid and ready for execution based on the provided nonce and other checks.
A payload with a hash of bytes(0) can never be submitted.
bytes(0) payloadHash can never be submitted
_assertAuthorized
initializable
verifiable
EndpointV2Alt
EndpointV2Alt is the LayerZero V2 endpoint contract designed for blockchain networks where ERC20 tokens are used as native tokens (instead of standard native tokens like ETH or BNB). This contract supports altFeeTokens, which are ERC20 tokens that can be used for paying messaging fees. The architecture is optimized to reduce gas costs by making certain configurations immutable.
LZ_OnlyAltToken
altFeeToken (an ERC20 token) is allowed. It enforces that only the designated ERC20 token is used for certain operations in the contract.
nativeErc20
nativeErc20 token is immutable, meaning that once it’s set, it cannot be changed. This saves gas by preventing unnecessary updates and checks. This token is used for paying fees when the chain doesn’t have a standard native token.
the altFeeToken is used for fees when the native token has no value
it is immutable for gas saving. only 1 endpoint for such chains
constructor
EndpointV2Alt contract, associating it with a unique Endpoint ID (_eid). It also specifies the owner of the contract and the altFeeToken (an ERC20 token) used for fees on the chain.
_payNative
_payNative processes payments in those tokens. If the supplied amount exceeds the required amount, the excess is refunded to the _refundAddress.
handling native token payments on endpoint
internal function
Parameters
| Name | Type | Description |
|---|---|---|
| _required | uint256 | the amount required |
| _supplied | uint256 | the amount supplied |
| _receiver | address | the receiver of the native token |
| _refundAddress | address | the address to refund the excess to |
_suppliedNative
setLzToken
lzToken). The function checks if the new token address matches the current one before applying changes. The lzToken can be used for paying fees when applicable.
check if lzToken is set to the same address
nativeToken
0x0. Otherwise, it returns the address of the ERC20 token acting as the native currency on the chain.
override this if the endpoint is charging ERC20 tokens as native
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | 0x0 if using native. otherwise the address of the native ERC20 token |
EndpointV2View
EndpointV2View is a contract used for viewing the state of LayerZero V2 messages, particularly related to whether a message is verifiable, executable, or initializable. This contract is typically used by other contracts or off-chain services that need to check the status of crosschain messages.
initialize
_endpoint). This endpoint is used for all subsequent verifications and message status checks. This function must be called before the contract can be used.
ExecutionState
NotExecutable: The message is not yet ready for execution.
VerifiedButNotExecutable: The message has been verified, but something is preventing its execution (e.g., not enough gas).
Executable: The message is ready to be executed.
Executed: The message has been successfully executed.
EndpointV2ViewUpgradeable
EndpointV2ViewUpgradeable is an upgradeable version of the EndpointV2View, adding support for certain upgrades while maintaining compatibility with existing state.
EMPTY_PAYLOAD_HASH
NIL_PAYLOAD_HASH
endpoint
EndpointV2ViewUpgradeable is interacting with. It is used for all message-related queries and verifications.
__EndpointV2View_init
__EndpointV2View_init_unchained
initializable
verifiable
executable
NotExecutable, VerifiedButNotExecutable, Executable, or Executed.
check if a message is executable.
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | enum ExecutionState | ExecutionState of Executed, Executable, or NotExecutable |
MessageLibManager
MessageLibManager manages the messaging libraries (msgLib) that are used for sending and receiving messages in the LayerZero protocol. It controls the libraries that each application (OApp) can use, either by directly assigning libraries or defaulting to LayerZero’s settings.
blockedLibrary
blockedLibrary is a specific library that is no longer allowed for sending or receiving messages.
registeredLibraries
isRegisteredLibrary
sendLibrary
address) and endpoint ID (uint32). Each OApp can specify a library it wants to use for sending messages to a specific endpoint.
receiveLibrary
address) and endpoint ID (uint32). Each OApp can specify a library for handling received messages.
receiveLibraryTimeout
defaultSendLibrary
uint32). If an OApp does not specify a send library, the default send library for that endpoint is used.
defaultReceiveLibrary
defaultReceiveLibraryTimeout
constructor
onlyRegistered
MessageLibManager can call certain functions. It restricts access to unregistered libraries, safeguarding the system from misuse.
isSendLib
isReceiveLib
onlyRegisteredOrDefault
onlySupportedEid
_eid). It checks if the library has been configured to handle messages for that endpoint.
check if the library supported the eid.
getRegisteredLibraries
getSendLibrary
_sender) and destination endpoint (_dstEid). If the OApp has not specified a library, the default one is used.
If the Oapp does not have a selected Send Library, this function will resolve to the default library
configured by LayerZero
Parameters
| Name | Type | Description |
|---|---|---|
| _sender | address | The address of the Oapp that is sending the message |
| _dstEid | uint32 | The destination endpoint id |
Return Values
| Name | Type | Description |
|---|---|---|
| lib | address | address of the Send Library |
isDefaultSendLibrary
getReceiveLibrary
_receiver) and source endpoint (_srcEid). If the OApp has not specified a library, the default one is used.
the receiveLibrary can be lazily resolved that if not set it will point to the default configured by LayerZero
isValidReceiveLibrary
registerLibrary
MessageLibManager. Only the contract owner can register new libraries.
all libraries have to implement the erc165 interface to prevent wrong configurations
only owner
setDefaultSendLibrary
setDefaultReceiveLibrary
setDefaultReceiveLibraryTimeout
Parameters
| Name | Type | Description |
|---|---|---|
| _eid | uint32 | |
| _lib | address | |
| _expiry | uint256 | the block number when lib expires |
isSupportedEid
setSendLibrary
setReceiveLibrary
Parameters
| Name | Type | Description |
|---|---|---|
| _oapp | address | |
| _eid | uint32 | |
| _newLib | address | |
| _gracePeriod | uint256 | the number of blocks from now until oldLib expires |
setReceiveLibraryTimeout
Parameters
| Name | Type | Description |
|---|---|---|
| _oapp | address | |
| _eid | uint32 | |
| _lib | address | |
| _expiry | uint256 | the block number when lib expires |
setConfig
getConfig
_assertAuthorized
MessagingChannel
TheMessagingChannel contract manages the lifecycle of messages sent across different blockchains using the LayerZero protocol. It tracks the nonces, payloads, and statuses of messages to ensure censorship resistance and reliable crosschain communication.
EMPTY_PAYLOAD_HASH
NIL_PAYLOAD_HASH
eid
lazyInboundNonce
inboundPayloadHash
sender, source endpoint, and nonce.
outboundNonce
sender, destination endpoint, and receiver. Nonces ensure that messages are delivered in order and without duplication.
constructor
_eid). This ID is used to identify the channel in LayerZero’s messaging system.
Parameters
| Name | Type | Description |
|---|---|---|
| _eid | uint32 | is the universally unique id (UUID) of this deployed Endpoint |
_outbound
_inbound
_inbound function updates the inbound message state lazily. It doesn’t immediately increment the nonce, allowing for out-of-order message verification while preserving censorship resistance.
inbound won’t update the nonce eagerly to allow unordered verification
instead, it will update the nonce lazily when the message is received
messages can only be cleared in order to preserve censorship-resistance
inboundNonce
_hasPayloadHash
skip
nilify
burn
_clearPayload
nextGuid
_assertAuthorized
MessagingComposer
TheMessagingComposer contract is responsible for composing LayerZero messages, enabling applications (OApps) to send messages in smaller piecewise operations or add extra steps to messages.
composeQueue
sendCompose
sendCompose function allows an OApp to send a composed message fragment to the receiver. The sender must be authenticated, ensuring that only the intended OApp can send the message. Multiple fragments can be sent with the same GUID, allowing for more flexible message composition.
the Oapp sends the lzCompose message to the endpoint
the composer MUST assert the sender because anyone can send compose msg with this function
with the same GUID, the Oapp can send compose to multiple _composer at the same time
authenticated by the msg.sender
Parameters
| Name | Type | Description |
|---|---|---|
| _to | address | the address which will receive the composed message |
| _guid | bytes32 | the message guid |
| _index | uint16 | |
| _message | bytes | the message |
lzCompose
lzCompose function executes a composed message from the sender to the receiver. It provides the execution context (caller and extraData) to the receiver, allowing for additional validation.
execute a composed messages from the sender to the composer (receiver)
the execution provides the execution context (caller, extraData) to the receiver.
the receiver can optionally assert the caller and validate the untrusted extraData
can not re-entrant
Parameters
| Name | Type | Description |
|---|---|---|
| _from | address | the address which sends the composed message. in most cases, it is the Oapp’s address. |
| _to | address | the address which receives the composed message |
| _guid | bytes32 | the message guid |
| _index | uint16 | |
| _message | bytes | the message |
| _extraData | bytes | the extra data provided by the executor. this data is untrusted and should be validated. |
lzComposeAlert
lzComposeAlert function is triggered when an issue occurs during message composition. It allows the contract to report why a composed message could not be processed.
Parameters
| Name | Type | Description |
|---|---|---|
| _from | address | the address which sends the composed message |
| _to | address | the address which receives the composed message |
| _guid | bytes32 | the message guid |
| _index | uint16 | |
| _gas | uint256 | |
| _value | uint256 | |
| _message | bytes | the message |
| _extraData | bytes | the extra data provided by the executor |
| _reason | bytes | the reason why the message is not received |
MessagingContext
TheMessagingContext contract acts as a guard for preventing reentrancy and also provides execution context for messages sent and received in LayerZero.
this contract acts as a non-reentrancy guard and a source of messaging context
the context includes the remote eid and the sender address
it separates the send and receive context to allow messaging receipts (send back on receive())
sendContext
sendContext modifier sets the execution context for the message being sent. It encodes the context as a combination of the destination endpoint ID (_dstEid) and the sender’s address. This context helps track the message’s origin and ensures that only authorized parties can interact with it.
the sendContext is set to 8 bytes 0s + 4 bytes eid + 20 bytes sender
isSendingMessage
isSendingMessage function returns true if the contract is in the process of sending a message. It helps prevent reentrant calls during message processing.
returns true if sending message
getSendContext
getSendContext function retrieves the current send context, returning the destination endpoint ID and sender’s address if a message is being sent. If no message is being sent, it returns (0, 0).
returns (eid, sender) if sending message, (0, 0) otherwise
_getSendContext
_getSendContext function decodes the provided _context into its component parts: the destination endpoint ID and the sender’s address. This function is used internally to reconstruct the message context when needed.
ILayerZeroComposer
ILayerZeroComposer defines the interface for composing messages in LayerZero. It standardizes how OApps send composed messages and ensures non-reentrancy.
lzCompose
lzCompose function is responsible for composing LayerZero messages from an OApp. To ensure that reentrancy is avoided, this function asserts that msg.sender is the corresponding EndpointV2 contract and from the correct OApp.
To ensure non-reentrancy, implementers of this interface MUST assert msg.sender is the corresponding EndpointV2 contract (i.e., onlyEndpointV2).
Parameters
| Name | Type | Description |
|---|---|---|
| _from | address | The address initiating the composition, typically the OApp where the lzReceive was called. |
| _guid | bytes32 | The unique identifier for the corresponding LayerZero src/dst tx. |
| _message | bytes | The composed message payload in bytes. NOT necessarily the same payload passed via lzReceive. |
| _executor | address | The address of the executor for the composed message. |
| _extraData | bytes | Additional arbitrary data in bytes passed by the entity who executes the lzCompose. |
MessagingParams
MessagingParams struct is used to define the parameters required for sending a LayerZero message. These parameters specify the destination endpoint, the message’s recipient, the actual message payload, and any additional options for the message.
| Name | Type | Description |
|---|---|---|
| dstEid | uint32 | The destination endpoint ID for the message. This identifies the chain and endpoint to which the message is being sent. |
| receiver | bytes32 | The address (in bytes32 format) of the receiver on the destination chain. |
| message | bytes | The actual message payload to be transmitted. |
| options | bytes | Additional options for the message, such as execution settings or gas limitations. |
| payInLzToken | bool | A boolean indicating whether the fees for the message will be paid in LayerZero (LZ) tokens. |
MessagingReceipt
MessagingReceipt struct provides information about a successfully sent LayerZero message, including a unique identifier (GUID), the nonce, and the fee details.
MessagingFee
MessagingFee struct details the costs involved in sending a message, specifying the native token fee and the fee in LayerZero tokens (if applicable).
Origin
ILayerZeroEndpointV2
This interface defines the main interaction points for the LayerZero V2 protocol, which includes message quoting, sending, verification, and event logging for the protocol.PacketSent
PacketVerified
PacketDelivered
LzReceiveAlert
LzTokenSet
DelegateSet
quote
send
verify
verifiable
initializable
lzReceive
clear
setLzToken
lzToken
nativeToken
setDelegate
ILayerZeroReceiver
This interface defines the core message-receiving functionality on LayerZero to be implemented by receiver applications.allowInitializePath
nextNonce
lzReceive
MessageLibType
Send: A library that only handles sending messages.Receive: A library that only handles receiving messages.SendAndReceive: A library that handles both sending and receiving messages.
IMessageLib
TheIMessageLib interface defines functions that allow configuration of messaging libraries, checking endpoint support, and obtaining versioning and library type details.
setConfig
getConfig
isSupportedEid
_eid).
version
messageLibType
Send, Receive, or SendAndReceive) as defined in the MessageLibType enum.
SetConfigParam
SetConfigParam struct defines configuration settings for registered Message Libraries.
IMessageLibManager
TheIMessageLibManager interface manages the registration of messaging libraries, setting default libraries, and handling receive library timeouts.
Timeout
Timeout struct defines the expiration settings for a messaging library that has been changed.
LibraryRegistered
DefaultSendLibrarySet
DefaultReceiveLibrarySet
DefaultReceiveLibraryTimeoutSet
SendLibrarySet
ReceiveLibrarySet
ReceiveLibraryTimeoutSet
registerLibrary
isRegisteredLibrary
getRegisteredLibraries
setDefaultSendLibrary
defaultSendLibrary
setDefaultReceiveLibrary
defaultReceiveLibrary
setDefaultReceiveLibraryTimeout
defaultReceiveLibraryTimeout
isSupportedEid
isValidReceiveLibrary
setSendLibrary
getSendLibrary
isDefaultSendLibrary
setReceiveLibrary
getReceiveLibrary
setReceiveLibraryTimeout
receiveLibraryTimeout
setConfig
getConfig
IMessagingChannel
InboundNonceSkipped
PacketNilified
PacketBurnt
eid
skip
nilify
burn
nextGuid
inboundNonce
outboundNonce
inboundPayloadHash
lazyInboundNonce
IMessagingComposer
ComposeSent
ComposeDelivered
LzComposeAlert
composeQueue
sendCompose
lzCompose
IMessagingContext
isSendingMessage
getSendContext
Packet
Packet struct represents the data structure used for LayerZero messaging between endpoints. It includes important metadata such as sender, receiver, nonce, and the message itself.
ISendLib
TheISendLib interface defines the functions necessary for sending packets, estimating messaging fees, and handling fee withdrawals for LayerZero messaging.
send
_packet: The Packet struct containing the message to be sent._options: Byte-encoded options for the message._payInLzToken: Boolean flag indicating whether fees should be paid in LzToken.
MessagingFee: The fees for the message, divided into native and LzToken fees.encodedPacket: The encoded message packet in bytes.
quote
setTreasury
withdrawFee
withdrawLzTokenFee
AddressCast
TheAddressCast library provides utility functions for casting between addresses and their byte representations. It also includes error handling for invalid address sizes.
AddressCast_InvalidSizeForAddress
AddressCast_InvalidAddress
toBytes32
bytes32 representation of an address.
toBytes32
address to its bytes32 representation.
toBytes
bytes32 address to its byte array form, with a specified size.
toAddress
bytes32 representation of an address back to an address.
toAddress
address.
CalldataBytesLib
TheCalldataBytesLib provides functions to convert portions of calldata (byte arrays) into various Solidity types. These functions help when dealing with raw calldata.
toU8
uint8 starting at the given position.
toU16
uint16 starting at the given position.
toU32
uint32 starting at the given position.
toU64
uint64 starting at the given position.
toU128
uint128 starting at the given position.
toU256
uint256 starting at the given position.
toAddr
address starting at the given position.
toB32
bytes32 starting at the given position.
Errors
LZ_LzTokenUnavailable
LZ_InvalidReceiveLibrary
LZ_InvalidNonce
LZ_InvalidArgument
LZ_InvalidExpiry
LZ_InvalidAmount
LZ_OnlyRegisteredOrDefaultLib
LZ_OnlyRegisteredLib
LZ_OnlyNonDefaultLib
LZ_Unauthorized
LZ_DefaultSendLibUnavailable
LZ_DefaultReceiveLibUnavailable
LZ_PathNotInitializable
LZ_PathNotVerifiable
LZ_OnlySendLib
LZ_OnlyReceiveLib
LZ_UnsupportedEid
LZ_UnsupportedInterface
LZ_AlreadyRegistered
LZ_SameValue
LZ_InvalidPayloadHash
LZ_PayloadHashNotFound
LZ_ComposeNotFound
LZ_ComposeExists
LZ_SendReentrancy
LZ_NotImplemented
LZ_InsufficientFee
LZ_ZeroLzTokenFee
GUID
generate
Transfer
ADDRESS_ZERO
Transfer_NativeFailed
Transfer_ToAddressIsZero
native
token
nativeOrToken
BlockedMessageLib
supportsInterface
IERC165 and supportsInterface.
version
messageLibType
isSupportedEid
fallback
BitMaps
get
index is set.
set
index.
ExecutorOptions
WORKER_ID
OPTION_TYPE_LZRECEIVE
OPTION_TYPE_NATIVE_DROP
OPTION_TYPE_LZCOMPOSE
OPTION_TYPE_ORDERED_EXECUTION
Executor_InvalidLzReceiveOption
Executor_InvalidNativeDropOption
Executor_InvalidLzComposeOption
nextExecutorOption
Parameters
| Name | Type | Description |
|---|---|---|
| _options | bytes | [executor_id][executor_option][executor_id][executor_option]… executor_option = [option_size][option_type][option] option_size = len(option_type) + len(option) executor_id: uint8, option_size: uint16, option_type: uint8, option: bytes |
| _cursor | uint256 | the cursor to start decoding from |
Return Values
| Name | Type | Description |
|---|---|---|
| optionType | uint8 | the type of the option |
| option | bytes | the option of the executor |
| cursor | uint256 | the cursor to start decoding the next executor option |
decodeLzReceiveOption
decodeNativeDropOption
decodeLzComposeOption
encodeLzReceiveOption
encodeNativeDropOption
encodeLzComposeOption
PacketV1Codec
PACKET_VERSION
encode
encodePacketHeader
encodePayload
header
version
nonce
srcEid
sender
senderAddressB20
dstEid
receiver
receiverB20
guid
message
payload
payloadHash
MessageLibBase
This contract serves as a base for handling the communication between the LayerZero endpoint and a specific chain (referred to by itslocalEid). It simplifies the initialization and enforcement of endpoint-specific logic.
simply a container of endpoint address and local eid
endpoint
localEid
LZ_MessageLib_OnlyEndpoint
onlyEndpoint
constructor
localEid.
ReceiveLibBaseE2
This is the base contract for handling the receive-side logic of messages in LayerZero V2. It simplifies the process compared to V1 by removing complexities like nonce management and executor whitelisting. receive-side message library base contract on endpoint v2. it does not have the complication as the one of endpoint v1, such as nonce, executor whitelist, etc.constructor
supportsInterface
messageLibType
WorkerOptions
SetDefaultExecutorConfigParam
ExecutorConfig
SendLibBase
base contract for both SendLibBaseE1 and SendLibBaseE2TREASURY_MAX_COPY
treasuryGasLimit
treasuryNativeFeeCap
treasury
executorConfigs
fees
ExecutorFeePaid
TreasurySet
DefaultExecutorConfigsSet
ExecutorConfigSet
TreasuryNativeFeeCapSet
LZ_MessageLib_InvalidMessageSize
LZ_MessageLib_InvalidAmount
LZ_MessageLib_TransferFailed
LZ_MessageLib_InvalidExecutor
LZ_MessageLib_ZeroMessageSize
constructor
setDefaultExecutorConfigs
setTreasuryNativeFeeCap
getExecutorConfig
_assertMessageSize
_payExecutor
_payTreasury
_quote
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | nativeFee, lzTokenFee |
| [1] | uint256 |
_quoteTreasury
_parseTreasuryResult
_debitFee
_setTreasury
_setExecutorConfig
_quoteVerifier
_splitOptions
SendLibBaseE2
send-side message library base contract on endpoint v2. design: the high level logic is the same as SendLibBaseE1 1/ with added interfaces 2/ adapt the functions to the new types, like uint32 for eid, address for sender.NativeFeeWithdrawn
LzTokenFeeWithdrawn
LZ_MessageLib_NotTreasury
LZ_MessageLib_CannotWithdrawAltToken
constructor
supportsInterface
send
setTreasury
withdrawFee
withdrawLzTokenFee
quote
messageLibType
_payWorkers
_payVerifier
receive
Treasury
nativeBP
lzTokenFee
lzTokenEnabled
LZ_Treasury_LzTokenNotEnabled
getFee
payFee
setLzTokenEnabled
setNativeFeeBP
setLzTokenFee
withdrawLzToken
withdrawNativeFee
withdrawToken
_getFee
Worker
MESSAGE_LIB_ROLE
ALLOWLIST
DENYLIST
ADMIN_ROLE
workerFeeLib
allowlistSize
defaultMultiplierBps
priceFeed
supportedOptionTypes
constructor
Parameters
| Name | Type | Description |
|---|---|---|
| _messageLibs | address[] | array of message lib addresses that are granted the MESSAGE_LIB_ROLE |
| _priceFeed | address | price feed address |
| _defaultMultiplierBps | uint16 | default multiplier for worker fee |
| _roleAdmin | address | address that is granted the DEFAULT_ADMIN_ROLE (can grant and revoke all roles) |
| _admins | address[] | array of admin addresses that are granted the ADMIN_ROLE |
onlyAcl
hasAcl
- if one address is in the denylist -> deny
- else if address in the allowlist OR allowlist is empty (allows everyone)-> allow
- else deny_
Parameters
| Name | Type | Description |
|---|---|---|
| _sender | address | address to check |
setPaused
Parameters
| Name | Type | Description |
|---|---|---|
| _paused | bool | true to pause, false to unpause |
setPriceFeed
Parameters
| Name | Type | Description |
|---|---|---|
| _priceFeed | address | price feed address |
setWorkerFeeLib
Parameters
| Name | Type | Description |
|---|---|---|
| _workerFeeLib | address | worker fee lib address |
setDefaultMultiplierBps
Parameters
| Name | Type | Description |
|---|---|---|
| _multiplierBps | uint16 | default multiplier for worker fee |
withdrawFee
Parameters
| Name | Type | Description |
|---|---|---|
| _lib | address | message lib address |
| _to | address | address to withdraw fee to |
| _amount | uint256 | amount to withdraw |
withdrawToken
Parameters
| Name | Type | Description |
|---|---|---|
| _token | address | token address |
| _to | address | address to withdraw token to |
| _amount | uint256 | amount to withdraw |
setSupportedOptionTypes
getSupportedOptionTypes
_grantRole
Parameters
| Name | Type | Description |
|---|---|---|
| _role | bytes32 | role to grant |
| _account | address | address to grant role to |
_revokeRole
Parameters
| Name | Type | Description |
|---|---|---|
| _role | bytes32 | role to revoke |
| _account | address | address to revoke role from |
renounceRole
TargetParam
DVNParam
IExecutor
DstConfigParam
DstConfig
ExecutionParams
NativeDropParams
DstConfigSet
NativeDropApplied
dstConfig
IExecutorFeeLib
FeeParams
Executor_NoOptions
Executor_NativeAmountExceedsCap
Executor_UnsupportedOptionType
Executor_InvalidExecutorOptions
Executor_ZeroLzReceiveGasProvided
Executor_ZeroLzComposeGasProvided
Executor_EidNotSupported
getFeeOnSend
getFee
ILayerZeroExecutor
assignJob
getFee
ILayerZeroTreasury
getFee
payFee
IWorker
SetWorkerLib
SetPriceFeed
SetDefaultMultiplierBps
SetSupportedOptionTypes
Withdraw
Worker_NotAllowed
Worker_OnlyMessageLib
Worker_RoleRenouncingDisabled
setPriceFeed
priceFeed
setDefaultMultiplierBps
defaultMultiplierBps
withdrawFee
setSupportedOptionTypes
getSupportedOptionTypes
SafeCall
copied from https://github.com/nomad-xyz/ExcessivelySafeCall/blob/main/src/ExcessivelySafeCall.sol.safeCall
Parameters
| Name | Type | Description |
|---|---|---|
| _target | address | The address to call |
| _gas | uint256 | The amount of gas to forward to the remote contract |
| _value | uint256 | The value in wei to send to the remote contract to memory. |
| _maxCopy | uint16 | The maximum number of bytes of returndata to copy to memory. |
| _calldata | bytes | The data to send to the remote contract |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | success and returndata, as .call(). Returndata is capped to _maxCopy bytes. |
| [1] | bytes |
safeStaticCall
Parameters
| Name | Type | Description |
|---|---|---|
| _target | address | The address to call |
| _gas | uint256 | The amount of gas to forward to the remote contract |
| _maxCopy | uint16 | The maximum number of bytes of returndata to copy to memory. |
| _calldata | bytes | The data to send to the remote contract |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bool | success and returndata, as .call(). Returndata is capped to _maxCopy bytes. |
| [1] | bytes |
DVNMock
Executed
vid
constructor
execute
verify
ExecutorMock
NativeDropMeta
NativeDropped
Executed301
Executed302
dstEid
constructor
nativeDrop
nativeDropAndExecute301
execute301
nativeDropAndExecute302
_nativeDrop
LzReceiveParam
NativeDropParam
IReceiveUlnView
verifiable
Verification
ReceiveUlnBase
includes the utility functions for checking ULN states and logicshashLookup
PayloadVerified
LZ_ULN_InvalidPacketHeader
LZ_ULN_InvalidPacketVersion
LZ_ULN_InvalidEid
LZ_ULN_Verifying
verifiable
assertHeader
_verify
_verified
_verifyAndReclaimStorage
_assertHeader
_checkVerifiable
SendUlnBase
includes the utility functions for checking ULN states and logicsDVNFeePaid
_splitUlnOptions
_payDVNs
_assignJobs
_quoteDVNs
_getFees
UlnConfig
SetDefaultUlnConfigParam
UlnBase
includes the utility functions for checking ULN states and logicsDEFAULT
NIL_DVN_COUNT
NIL_CONFIRMATIONS
ulnConfigs
LZ_ULN_Unsorted
LZ_ULN_InvalidRequiredDVNCount
LZ_ULN_InvalidOptionalDVNCount
LZ_ULN_AtLeastOneDVN
LZ_ULN_InvalidOptionalDVNThreshold
LZ_ULN_InvalidConfirmations
LZ_ULN_UnsupportedEid
DefaultUlnConfigsSet
UlnConfigSet
setDefaultUlnConfigs
- its values are all LITERAL (e.g. 0 is 0). whereas in the oapp ULN config, 0 (default value) points to the default ULN config this design enables the oapp to point to DEFAULT config without explicitly setting the config
- its configuration is more restrictive than the oapp ULN config that a) it must not use NIL value, where NIL is used only by oapps to indicate the LITERAL 0 b) it must have at least one DVN_
getUlnConfig
getAppUlnConfig
_setUlnConfig
_isSupportedEid
_assertSupportedEid
ExecuteParam
ISendLibBase
fees
IReceiveUln
verify
ReceiveLibParam
DVNAdapterBase
base contract for DVN adapters _limitations:- doesn’t accept alt token
- doesn’t respect block confirmations_
DVNAdapter_InsufficientBalance
DVNAdapter_NotImplemented
DVNAdapter_MissingRecieveLib
ReceiveLibsSet
MAX_CONFIRMATIONS
receiveLibs
constructor
setReceiveLibs
_getAndAssertReceiveLib
_encode
_encodeEmpty
_decodeAndVerify
_withdrawFeeFromSendLib
_assertBalanceAndWithdrawFee
receive
DVNAdapterMessageCodec
DVNAdapter_InvalidMessageSize
PACKET_HEADER_SIZE
MESSAGE_SIZE
encode
decode
srcEid
IDVN
DstConfigParam
DstConfig
SetDstConfig
dstConfig
IDVNFeeLib
FeeParams
DVN_UnsupportedOptionType
DVN_EidNotSupported
getFeeOnSend
getFee
ILayerZeroDVN
AssignJobParam
assignJob
getFee
IReceiveUlnE2
should be implemented by the ReceiveUln302 contract and future ReceiveUln contracts on EndpointV2verify
commitVerification
DVNOptions
WORKER_ID
OPTION_TYPE_PRECRIME
DVN_InvalidDVNIdx
DVN_InvalidDVNOptions
groupDVNOptionsByIdx
Parameters
| Name | Type | Description |
|---|---|---|
| _options | bytes | [dvn_id][dvn_option][dvn_id][dvn_option]… dvn_option = [option_size][dvn_idx][option_type][option] option_size = len(dvn_idx) + len(option_type) + len(option) dvn_id: uint8, dvn_idx: uint8, option_size: uint16, option_type: uint8, option: bytes |
Return Values
| Name | Type | Description |
|---|---|---|
| dvnOptions | bytes[] | the grouped options, still share the same format of _options |
| dvnIndices | uint8[] | the dvn indices |
_insertDVNOptions
getNumDVNs
Parameters
| Name | Type | Description |
|---|---|---|
| _options | bytes | the format is the same as groupDVNOptionsByIdx |
nextDVNOption
Parameters
| Name | Type | Description |
|---|---|---|
| _options | bytes | the format is the same as groupDVNOptionsByIdx |
| _cursor | uint256 | the cursor to start decoding |
Return Values
| Name | Type | Description |
|---|---|---|
| optionType | uint8 | the type of the option |
| option | bytes | the option |
| cursor | uint256 | the cursor to start decoding the next option |
UlnOptions
TYPE_1
TYPE_2
TYPE_3
LZ_ULN_InvalidWorkerOptions
LZ_ULN_InvalidWorkerId
LZ_ULN_InvalidLegacyType1Option
LZ_ULN_InvalidLegacyType2Option
LZ_ULN_UnsupportedOptionType
decode
Parameters
| Name | Type | Description |
|---|---|---|
| _options | bytes | the options can be either legacy options (type 1 or 2) or type 3 options |
Return Values
| Name | Type | Description |
|---|---|---|
| executorOptions | bytes | the executor options, share the same format of type 3 options |
| dvnOptions | bytes | the dvn options, share the same format of type 3 options |
decodeLegacyOptions
Parameters
| Name | Type | Description |
|---|---|---|
| _optionType | uint16 | the legacy option type |
| _options | bytes | the legacy options, which still has the option type in the first 2 bytes |
Return Values
| Name | Type | Description |
|---|---|---|
| executorOptions | bytes | the executor options, share the same format of type 3 options Data format: legacy type 1: [extraGas] legacy type 2: [extraGas][dstNativeAmt][dstNativeAddress] extraGas: uint256, dstNativeAmt: uint256, dstNativeAddress: bytes |
AddressSizeConfig
addressSizes
AddressSizeSet
AddressSizeConfig_InvalidAddressSize
AddressSizeConfig_AddressSizeAlreadySet
setAddressSize
ILayerZeroReceiveLibrary
setConfig
getConfig
SetDefaultExecutorParam
ReceiveLibBaseE1
receive-side message library base contract on endpoint v1. design: 1/ it provides an internal execute function that calls the endpoint. It enforces the path definition on V1. 2/ it provides interfaces to configure executors that is whitelisted to execute the msg to prevent grievingexecutors
defaultExecutors
PacketDelivered
InvalidDst
DefaultExecutorsSet
ExecutorSet
LZ_MessageLib_InvalidExecutor
LZ_MessageLib_OnlyExecutor
constructor
setDefaultExecutors
getExecutor
_setExecutor
_execute
ReceiveUln301
ULN301 will be deployed on EndpointV1 and is for backward compatibility with ULN302 on EndpointV2. 301 can talk to both 301 and 302 This is a gluing contract. It simply parses the requests and forward to the super.impl() accordingly. In this case, it combines the logic of ReceiveUlnBase and ReceiveLibBaseE1CONFIG_TYPE_EXECUTOR
CONFIG_TYPE_ULN
LZ_ULN_InvalidConfigType
constructor
setConfig
commitVerification
verify
getConfig
version
VerificationState
IReceiveUln301
assertHeader
addressSizes
endpoint
verifiable
getUlnConfig
ReceiveUln301View
endpoint
receiveUln301
localEid
initialize
executable
verifiable
SendLibBaseE1
send-side message library base contract on endpoint v1. design: 1/ it enforces the path definition on V1 and interacts with the nonce contract 2/ quote: first executor, then verifier (e.g. DVNs), then treasury 3/ send: first executor, then verifier (e.g. DVNs), then treasury. the treasury pay much be DoS-proofnonceContract
treasuryFeeHandler
lzToken
PacketSent
NativeFeeWithdrawn
LzTokenSet
constructor
send
setLzToken
setTreasury
withdrawFee
estimateFees
_assertPath
_payLzTokenFee
_outbound
- asserts path
- increments the nonce
- assemble packet_
Return Values
| Name | Type | Description |
|---|---|---|
| packet | struct Packet | to be sent to workers |
_payWorkers
_payVerifier
SendUln301
ULN301 will be deployed on EndpointV1 and is for backward compatibility with ULN302 on EndpointV2. 301 can talk to both 301 and 302 This is a gluing contract. It simply parses the requests and forward to the super.impl() accordingly. In this case, it combines the logic of SendUlnBase and SendLibBaseE1CONFIG_TYPE_EXECUTOR
CONFIG_TYPE_ULN
LZ_ULN_InvalidConfigType
constructor
setConfig
getConfig
version
isSupportedEid
_quoteVerifier
_payVerifier
_splitOptions
TreasuryFeeHandler
endpoint
LZ_TreasuryFeeHandler_OnlySendLibrary
LZ_TreasuryFeeHandler_OnlyOnSending
LZ_TreasuryFeeHandler_InvalidAmount
constructor
payFee
IMessageLibE1
extends ILayerZeroMessagingLibrary instead of ILayerZeroMessagingLibraryV2 for reducing the contract sizeLZ_MessageLib_InvalidPath
LZ_MessageLib_InvalidSender
LZ_MessageLib_InsufficientMsgValue
LZ_MessageLib_LzTokenPaymentAddressMustBeSender
setLzToken
setTreasury
withdrawFee
version
INonceContract
increment
ITreasuryFeeHandler
payFee
IUltraLightNode301
commitVerification
NonceContractMock
OnlySendLibrary
endpoint
outboundNonce
constructor
increment
ReceiveUln302
This is a gluing contract. It simply parses the requests and forward to the super.impl() accordingly. In this case, it combines the logic of ReceiveUlnBase and ReceiveLibBaseE2CONFIG_TYPE_ULN
LZ_ULN_InvalidConfigType
constructor
supportsInterface
setConfig
commitVerification
verify
getConfig
isSupportedEid
version
VerificationState
IReceiveUln302
assertHeader
verifiable
getUlnConfig
ReceiveUln302View
receiveUln302
localEid
initialize
verifiable
_endpointVerifiable
SendUln302
This is a gluing contract. It simply parses the requests and forward to the super.impl() accordingly. In this case, it combines the logic of SendUlnBase and SendLibBaseE2CONFIG_TYPE_EXECUTOR
CONFIG_TYPE_ULN
LZ_ULN_InvalidConfigType
constructor
setConfig
getConfig
version
isSupportedEid
_quoteVerifier
_payVerifier
_splitOptions
WorkerUpgradeable
MESSAGE_LIB_ROLE
ALLOWLIST
DENYLIST
ADMIN_ROLE
workerFeeLib
allowlistSize
defaultMultiplierBps
priceFeed
supportedOptionTypes
__Worker_init
Parameters
| Name | Type | Description |
|---|---|---|
| _messageLibs | address[] | array of message lib addresses that are granted the MESSAGE_LIB_ROLE |
| _priceFeed | address | price feed address |
| _defaultMultiplierBps | uint16 | default multiplier for worker fee |
| _roleAdmin | address | address that is granted the DEFAULT_ADMIN_ROLE (can grant and revoke all roles) |
| _admins | address[] | array of admin addresses that are granted the ADMIN_ROLE |
__Worker_init_unchained
onlyAcl
hasAcl
- if one address is in the denylist -> deny
- else if address in the allowlist OR allowlist is empty (allows everyone)-> allow
- else deny_
Parameters
| Name | Type | Description |
|---|---|---|
| _sender | address | address to check |
setPaused
Parameters
| Name | Type | Description |
|---|---|---|
| _paused | bool | true to pause, false to unpause |
setPriceFeed
Parameters
| Name | Type | Description |
|---|---|---|
| _priceFeed | address | price feed address |
setWorkerFeeLib
Parameters
| Name | Type | Description |
|---|---|---|
| _workerFeeLib | address | worker fee lib address |
setDefaultMultiplierBps
Parameters
| Name | Type | Description |
|---|---|---|
| _multiplierBps | uint16 | default multiplier for worker fee |
withdrawFee
Parameters
| Name | Type | Description |
|---|---|---|
| _lib | address | message lib address |
| _to | address | address to withdraw fee to |
| _amount | uint256 | amount to withdraw |
withdrawToken
Parameters
| Name | Type | Description |
|---|---|---|
| _token | address | token address |
| _to | address | address to withdraw token to |
| _amount | uint256 | amount to withdraw |
setSupportedOptionTypes
getSupportedOptionTypes
_grantRole
Parameters
| Name | Type | Description |
|---|---|---|
| _role | bytes32 | role to grant |
| _account | address | address to grant role to |
_revokeRole
Parameters
| Name | Type | Description |
|---|---|---|
| _role | bytes32 | role to revoke |
| _account | address | address to revoke role from |