Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
LayerZero Endpoint
copy icon
LayerZero
• version 1.0.0
Communication
Protocol
Crosschain
Audited

LayerZero Endpoint

Audited

Messages in LayerZero are sent and received by LayerZero Endpoints, which handle message transmission, verification, and receipt.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

LayerZero

Last Publish

11/25/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
send(uint16,address,address) :
This function is used to send a transaction to a different blockchain. It takes in a destination chain ID, a destination address, a payload, a refund address, a ZROPayment address, and adapter parameters as arguments. It then looks up the LibraryConfig storage for the sender, increments the outboundNonce for the destination chain, and calls the send function of the getSendLibrary function with the sender, nonce, destination chain ID, destination address, payload, refund address, ZROPayment address, and adapter parameters as arguments. (autogenerated documentation)
receivePayload(uint16,address,uint64) :
This function is used to receive payloads from other chains. It takes in a source chain ID, source address, destination address, nonce, gas limit, and payload as parameters. It first checks that the nonce is correct, then checks that the library address is valid. It then stores the payload in a storage variable and emits an event. If an error occurs, the payload is still stored and an event is emitted with the error. (autogenerated documentation)
retryPayload(uint16) :
This function is used to retry a payload that was previously sent to a LayerZero receiver. It takes in the source chain ID, source address, and payload as parameters. It then checks if there is a stored payload associated with the source chain ID and address, and if so, it checks if the payload matches the stored payload. If the payload is valid, it retrieves the destination address from the stored payload and calls the lzReceive function on the LayerZero receiver. It then clears the stored payload and emits an event to indicate that the payload has been cleared. (autogenerated documentation)
newVersion(address) :
This function allows the owner of the contract to add a new version of the LayerZeroMessagingLibrary contract. It requires that the address of the new version is not the zero address, and that the latest version is less than 65535. It then increments the latest version and stores the address of the new version in the libraryLookup mapping. Finally, it emits an event to signal that a new version has been added. (autogenerated documentation)
setDefaultSendVersion(uint16) :
This function sets the default send version for the LayerZero contract. It takes in a uint16 parameter, _newDefaultSendVersion, which is checked against the validVersion function to ensure it is a valid version. If the version is valid, the defaultSendVersion and defaultSendLibrary variables are set to the new version and the corresponding library address, respectively. Finally, an event is emitted to signal that the default send version has been set. (autogenerated documentation)
setDefaultReceiveVersion(uint16) :
This function allows the owner of the contract to set the default receive version. The function requires that the new version is greater than 0 and that it is a valid version. If these conditions are met, the default receive version is set to the new version and the default receive library address is set to the address of the library associated with the new version. Finally, an event is emitted to indicate that the default receive version has been set. (autogenerated documentation)
setConfig(uint16,uint16) :
This function sets the configuration for a given version, chain ID, and config type. It requires that the version is valid, that the version is not the BLOCK_VERSION, and that the defaultSendVersion and defaultReceiveVersion are the same. It then calls the setConfig function of the libraryLookup for the given version, passing in the chain ID, the sender of the message, the config type, and the config. (autogenerated documentation)
setSendVersion(uint16) :
This function sets the send version of a user's library configuration. It takes in a uint16 _newVersion as an argument and checks if it is a valid version using the validVersion() function. It then looks up the user's library configuration in the uaConfigLookup mapping and sets the sendVersion to the new version. It also sets the sendLibrary to the library associated with the new version using the libraryLookup mapping. Finally, it emits an event to indicate that the send version has been set. (autogenerated documentation)
setReceiveVersion(uint16) :
This function sets the receive version of a given user address. It takes in a uint16 _newVersion as an argument and checks if it is a valid version using the validVersion() function. It then looks up the user address in the uaConfigLookup mapping and sets the receiveVersion to the new version. It also sets the receiveLibraryAddress to the address of the library associated with the new version. Finally, it emits an event to signal that the receive version has been set. (autogenerated documentation)
forceResumeReceive(uint16) :
This function is used to force a resume of a receive operation on the LayerZero protocol. It takes two parameters, a source chain ID and a source address, and uses them to look up a stored payload in the storedPayload mapping. It then checks that the stored payload exists and that the destination address matches the caller's address. If these checks pass, the payload length and destination address are reset to 0 and the payload hash is set to 0. Finally, an event is emitted to indicate that the force resume receive operation has been completed. (autogenerated documentation)
estimateFees(uint16,address,bool) :
This function estimates the fees associated with sending a message from one chain to another. It takes in the destination chain ID, the user application address, the payload, a boolean indicating whether the payment should be made in ZRO, and adapter parameters as inputs. It then looks up the library configuration associated with the user application address and uses the appropriate library to estimate the fees. It returns the native fee and the ZRO fee as outputs. (autogenerated documentation)
_getSendLibrary() :
This function is used to get the messaging library used for sending messages. It takes in two parameters, a LibraryConfig storage variable and a uaConfig variable. If the uaConfig variable's sendVersion is set to the default version, the defaultSendLibrary is returned. Otherwise, the uaConfig variable's sendLibrary is returned. (autogenerated documentation)
getSendLibraryAddress(address) :
This function is used to retrieve the address of the send library associated with a given user application. It takes in the address of the user application as an argument and returns the address of the send library associated with it. The function first looks up the LibraryConfig storage associated with the user application address and checks the sendVersion associated with it. If the sendVersion is set to BLOCK_VERSION, an error is thrown. If the sendVersion is set to DEFAULT_VERSION, the address of the defaultSendLibrary is returned. Otherwise, the address of the sendLibrary associated with the user application is returned. (autogenerated documentation)
getReceiveLibraryAddress(address) :
This function retrieves the address of the receive library associated with a given user application address. It first looks up the LibraryConfig storage associated with the user application address, and checks the receiveVersion field. If the receiveVersion is set to BLOCK_VERSION, an error is thrown. If the receiveVersion is set to DEFAULT_VERSION, the address of the default receive library is returned. Otherwise, the address of the receive library associated with the user application address is returned. (autogenerated documentation)
isSendingPayload() :
This function checks whether the contract is currently in the process of sending a payload. It does this by checking the value of the _send_entered_state variable, which is set to _ENTERED when the contract is sending a payload. If the variable is set to _ENTERED, the function returns true, otherwise it returns false. (autogenerated documentation)
isReceivingPayload() :
This function checks if the contract is currently receiving a payload. It does this by checking the value of the _receive_entered_state variable, which is set to _ENTERED when the contract is receiving a payload. If the variable is set to _ENTERED, the function returns true, otherwise it returns false. (autogenerated documentation)
getInboundNonce(uint16) :
This function retrieves the inbound nonce associated with a given source chain ID and source address. The inbound nonce is a 64-bit unsigned integer that is used to track the number of transactions sent from the source address to the destination chain. The function takes two parameters: a 16-bit unsigned integer representing the source chain ID and a byte array representing the source address. It then returns the inbound nonce associated with the given source chain ID and source address. (autogenerated documentation)
getOutboundNonce(uint16,address) :
This function retrieves the outbound nonce associated with a given destination chain ID and source address. The outbound nonce is stored in a mapping of uint16 (destination chain ID) to a mapping of address (source address) to uint64 (outbound nonce). The function takes in the destination chain ID and source address as parameters and returns the outbound nonce associated with them. (autogenerated documentation)
getChainId() :
This function is an override of the getChainId() function, which is used to retrieve the chain ID of the current Ethereum network. It returns a uint16 value, which is the chain ID of the current network. (autogenerated documentation)
getSendVersion(address) :
This function retrieves the send version associated with a given user application address. It does this by first looking up the LibraryConfig storage associated with the user application address in the uaConfigLookup mapping. If the sendVersion associated with the LibraryConfig is equal to the default version, the defaultSendVersion is returned. Otherwise, the sendVersion associated with the LibraryConfig is returned. (autogenerated documentation)
getReceiveVersion(address) :
This function retrieves the receive version associated with a given user application address. It does this by first looking up the LibraryConfig storage associated with the user application address in the uaConfigLookup mapping. If the receiveVersion associated with the LibraryConfig is equal to the default version, the defaultReceiveVersion is returned. Otherwise, the receiveVersion associated with the LibraryConfig is returned. (autogenerated documentation)
getConfig(uint16,uint16,address) :
This function is used to retrieve a configuration from the LayerZero library. It takes in a version, chain ID, user application address, and configuration type as parameters. It then checks to make sure the version is valid and that the default send and receive versions are the same. If the version is the default version, it sets the version to the default send version. Finally, it returns the configuration from the library lookup using the version, chain ID, user application address, and configuration type as parameters. (autogenerated documentation)
hasStoredPayload(uint16) :
This function checks if a stored payload exists for a given source chain ID and source address. It does this by accessing the storedPayload mapping, which is a mapping of source chain IDs to source addresses, and then checking if the payloadHash stored in the StoredPayload struct is not equal to the bytes32 value of 0. If it is not equal to 0, then the function returns true, indicating that a stored payload exists. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i layer-zero-endpoint
copy icon

Last Publish

11/25/2022

Version

1.0.0

Creator

LayerZero

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.