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 Ultra Light Node V2
copy icon
LayerZero
• version 1.0.0
Communication
Protocol
Crosschain
Node
Audited

LayerZero Ultra Light Node V2

Audited

ULN is a messaging protocol, firstly introduced in the LayerZero white paper, that allows lightweight cross-chain messaging.

*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
validateTransactionProof(uint16,address,bytes32,bytes32) :
This function is used to validate a transaction proof from a source chain. It first checks that the relayer is the sender of the transaction, then it checks that there are enough block confirmations for the transaction. It then checks that the packet contains the correct source and destination chain IDs, addresses, and nonce. If the destination address is not a contract, an event is emitted. Finally, the payload is sent to the endpoint. (autogenerated documentation)
send(address,uint64,,uint16,address,address) :
This function is used to send a packet of data from one chain to another. It takes in an address, a destination chain ID, a path, a payload, a refund address, a ZRO payment address, and adapter parameters as parameters. It then checks that the destination chain ID exists, and that the path data is correct. It then increments the nonce for the destination chain, and retrieves the application configuration for the destination chain. It then handles the relayer, oracle, and protocol fees, and refunds any remaining amount to the refund address. Finally, it encodes the nonce, local chain ID, address, destination chain ID, destination address, and payload into a packet, and emits the packet. (autogenerated documentation)
_handleRelayer(uint16,address) :
This function is used to handle the relayer for a given transaction. It takes in the destination chain ID, application configuration, user address, payload size, and adapter parameters as inputs. It then assigns a job to the relayer, credits the relayer for their fee, and emits an event with the adapter parameters and outbound proof type. (autogenerated documentation)
_handleOracle(uint16,address) :
This function is used to handle the Oracle for a given chain. It takes in the destination chain ID, an ApplicationConfiguration memory object, and an address for the user application as parameters. It then retrieves the address of the Oracle from the ApplicationConfiguration object and calls the assignJob() function on the ILayerZeroOracleV2 contract, passing in the destination chain ID, the outbound proof type, the outbound block confirmations, and the user application address. Finally, it credits the native fee to the Oracle address. (autogenerated documentation)
_handleProtocolFee(address,address) :
This function is used to handle the protocol fees associated with a transaction. It takes in the relayer fee, oracle fee, user address, and ZRO payment address as parameters. It first checks if the payment should be made in native currency or ZRO tokens. It then calculates the protocol fee and credits the treasury address with the native currency fee if applicable. If the payment is to be made in ZRO tokens, it transfers the protocol fee from the ZRO payment address to the contract address and adds it to the treasuryZROFees. (autogenerated documentation)
_creditNativeFee(address) :
This function is an internal function that is used to credit native fees to a given address. It takes in two parameters, an address of the receiver and an amount of the native fees. It then adds the amount to the existing native fees of the receiver and stores the result in the nativeFees mapping. (autogenerated documentation)
updateHash(uint16,bytes32,bytes32) :
This function updates the hashLookup mapping with the data provided by an oracle. It requires that the oracle provide the source chain ID, the lookup hash, the number of confirmations, and the block data. The function then checks to make sure that the number of confirmations provided is greater than the number of confirmations stored in the mapping. If this is true, the function updates the mapping with the new data and emits an event to notify other contracts of the update. (autogenerated documentation)
getAppConfig(uint16,address) :
This function retrieves the ApplicationConfiguration associated with a given remote chain ID and user address. It does this by calling the internal _getAppConfig() function, which looks up the ApplicationConfiguration in a mapping of remote chain IDs and user addresses. (autogenerated documentation)
_getAppConfig(uint16,address) :
This function is used to retrieve the application configuration for a given remote chain ID and user address. It first checks if the configuration is stored in the appConfig mapping, and if not, it retrieves the default configuration from the defaultAppConfig mapping. If any of the configuration values are not set, it sets them to the default values. Finally, it returns the configuration. (autogenerated documentation)
setConfig(uint16,address) :
This function allows a user to set a configuration for a given user address and remote chain ID. The configuration type and the configuration data are passed as parameters. Depending on the configuration type, the function will decode the configuration data and store it in the application configuration storage. Finally, an event is emitted to notify of the configuration update. (autogenerated documentation)
getConfig(uint16,address) :
This function is used to retrieve the configuration settings for a given application on a given remote chain. It takes in two parameters, the remote chain ID and the address of the application, and an integer representing the type of configuration to be retrieved. It then checks the application configuration storage for the given application and remote chain ID, and if the configuration is not found, it returns the default configuration for that remote chain. Finally, it returns the requested configuration as a byte array. (autogenerated documentation)
estimateFees(uint16,address,bool) :
This function estimates the fees associated with a transaction on Layer Zero. It takes in the destination chain ID, the user address, the payload, a boolean indicating whether the payment is in ZRO, and adapter parameters as inputs. It then retrieves the application configuration for the user address, and sets the adapter parameters to either the default parameters or the parameters provided. It then calls the relayer and oracle contracts to get the relayer and oracle fees, and calls the treasury contract to get the protocol fee. Finally, it adds the relayer and oracle fees to the native fee, and sets the ZRO fee if the payment is in ZRO. (autogenerated documentation)
withdrawZRO(address) :
This function allows the treasury contract to withdraw a specified amount of ZRO tokens from the LayerZero treasury. It requires that the msg.sender is the treasury contract, and subtracts the amount from the treasuryZROFees variable. It then uses the safeTransfer function to securely transfer the specified amount of ZRO tokens to the specified address. Finally, it emits an event to log the withdrawal. (autogenerated documentation)
withdrawNative(address) :
This function allows a user to withdraw a specified amount of native tokens from their LayerZero account. It requires that the address to which the tokens are being sent is not the zero address, and then calls the recipient's address with the specified amount of tokens. If the call is successful, an event is emitted to confirm the withdrawal. (autogenerated documentation)
setLayerZeroToken(address) :
This function allows the owner of the contract to set the address of the LayerZeroToken contract. It requires that the address provided is not the zero address, and then sets the layerZeroToken variable to the IERC20 interface of the address provided. Finally, it emits an event to signal that the LayerZeroToken address has been set. (autogenerated documentation)
setTreasury(address) :
This function allows the owner of the LayerZero contract to set the address of the treasury contract. It requires that the address of the treasury contract is not the zero address, and then sets the treasuryContract variable to the address of the treasury contract. It then emits an event to signal that the treasury has been set. (autogenerated documentation)
addInboundProofLibraryForChain(uint16,address) :
This function adds an inbound proof library for a given chain ID. It requires that the library address is not the zero address, and that the maximum library ID for the given chain ID is less than 65535. It then increments the maximum library ID for the given chain ID and stores the library address in the inboundProofLibrary mapping. Finally, it emits an event to signal that the library has been added. (autogenerated documentation)
enableSupportedOutboundProof(uint16,uint16) :
This function enables a specific type of outbound proof for a given chain ID. It is only accessible to the contract owner, and emits an event when it is called. The function takes two parameters, a chain ID and a proof type, and sets the corresponding value in the supportedOutboundProof mapping to true. This allows the contract to recognize and process outbound proofs of the specified type for the given chain ID. (autogenerated documentation)
setDefaultConfigForChainId(uint16,uint16,uint64,address,uint16,uint64,address) :
This function allows the owner of the LayerZero contract to set the default configuration for a given chain ID. It requires the owner to provide the inbound proof library version, inbound block confirmations, relayer address, outbound proof type, outbound block confirmations, and oracle address. If all of the provided parameters are valid, the default configuration for the given chain ID is set and an event is emitted. (autogenerated documentation)
setDefaultAdapterParamsForChainId(uint16,uint16) :
This function allows the owner of the contract to set the default adapter parameters for a given chain ID and proof type. The adapter parameters are passed in as a bytes calldata parameter and stored in a mapping of chain ID and proof type to adapter parameters. An event is also emitted to notify of the change. (autogenerated documentation)
setRemoteUln(uint16,bytes32) :
This function allows the owner of the contract to set the Universal Location Number (ULN) for a remote chain. The function takes two parameters, a uint16 _remoteChainId and a bytes32 _remoteUln. It first checks to make sure that the ULN for the remote chain has not already been set, and then sets the ULN for the remote chain to the given bytes32 _remoteUln. Finally, it emits an event to signal that the ULN has been set. (autogenerated documentation)
setChainAddressSize(uint16) :
This function sets the address size for a given chain ID. It is only accessible to the contract owner and requires that the address size for the given chain ID has not already been set. Once the address size is set, an event is emitted to notify the users of the change. (autogenerated documentation)
accruedNativeFee(address) :
This function returns the amount of native fees accrued by a given address. It works by accessing the nativeFees mapping, which stores the amount of native fees accrued by each address. The function takes in an address as an argument and returns the amount of native fees associated with that address. (autogenerated documentation)
getOutboundNonce(uint16) :
This function retrieves the outbound nonce for a given chain ID and path. It does this by calling the outboundNonce() function of the nonceContract contract, which is passed as an argument. The outboundNonce() function takes two parameters, the chain ID and the path, and returns the outbound nonce associated with them. (autogenerated documentation)
_isContract(address) :
This function is used to check if a given address is a contract address or not. It does this by using the extcodesize opcode to check the size of the code stored at the given address. If the size is not 0, then the address is a contract address. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i layer-zero-ultra-light-node-v2
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.