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 Relayer v2
copy icon
LayerZero
• version 1.0.0
Communication
Protocol
Crosschain
Relayer
Audited

LayerZero Relayer v2

Audited

Relayers work in tandem with an Oracle to transmit messages between chains. V2 improves transaction verification.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

LayerZero

Recent Use

🍞 0x705c downloaded

Last Publish

11/25/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
initialize(address) :
This function is used to initialize the contract. It sets the address of the ILayerZeroUltraLightNodeV2 contract to the variable uln, and sets the approved address of the contract to itself. The __Ownable_init() function is called to initialize the Ownable contract, which is used to manage the contract's ownership. (autogenerated documentation)
setDstPrice(uint16,uint128,uint128) :
This function sets the destination price for a given chain ID. It takes three parameters: the chain ID, the destination price ratio, and the destination gas price in Wei. The function stores the given parameters in the dstPriceLookup mapping, and emits an event to signal that the destination price has been set. (autogenerated documentation)
setDstConfig(uint16,uint16,uint128,uint64,uint64) :
This function sets the configuration parameters for a given destination chain and outbound proof type. The parameters are the maximum native amount cap, the base gas, and the gas per byte. These parameters are stored in the dstConfigLookup mapping, which is indexed by the chain ID and outbound proof type. An event is also emitted to signal that the configuration has been set. (autogenerated documentation)
setStargateAddress(address) :
This function sets the address of the Stargate Bridge contract. It can only be called by an approved address, and it takes an address as an argument. This address is then stored in the stargateBridgeAddress variable. (autogenerated documentation)
setApprovedAddress(address,bool) :
This function allows the owner of the contract to approve or disapprove a given address as a relayer. It takes two parameters, an address and a boolean value. If the boolean value is set to true, the address is approved as a relayer, and if it is set to false, the address is disapproved as a relayer. The function then emits an event, ApproveAddress, which contains the address and the boolean value. (autogenerated documentation)
setPause(bool) :
This function sets the paused state of the contract to the boolean value passed in as an argument. It can only be called by the contract owner. If the paused state is set to true, the contract will be paused and no further transactions can be made. (autogenerated documentation)
_getPrices(uint16,uint16) :
This function is used to calculate the base price and price per byte for a transaction on a destination chain. It takes in the destination chain ID, outbound proof type, address, and adapter parameters as inputs. It first checks that the adapter parameters are of the correct length and that the transaction type is supported. It then retrieves the destination price and configuration from the lookups and calculates the total remote token amount. It then calculates the base price and price per byte by multiplying the total remote token amount by the destination price ratio and dividing by 10^10. (autogenerated documentation)
getFee(uint16,uint16,address) :
This function calculates the fee for a transaction on a given blockchain. It takes in the destination chain ID, the type of outbound proof, the user application address, the payload size, and adapter parameters as inputs. It then calls the _getPrices() function to retrieve the base price and price per byte for the transaction. Finally, it returns the fee as the sum of the base price and the product of the payload size and the price per byte. (autogenerated documentation)
isApproved(address) :
This function checks if a given address is approved to act as a relayer. It does this by accessing the approvedAddresses mapping, which stores a boolean value for each address. If the address is found in the mapping and the boolean value is true, the function returns true, indicating that the address is approved. If the address is not found or the boolean value is false, the function returns false, indicating that the address is not approved. (autogenerated documentation)
assignJob(uint16,uint16,address) :
This function assigns a job to the relayer. It takes in parameters such as the destination chain ID, outbound proof type, user application address, payload size, and adapter parameters. It then calculates the total fee for the job based on the base price and the price per byte of the payload. Finally, it emits an AssignJob event and returns the total fee. (autogenerated documentation)
withdrawFee(address) :
This function allows an approved address to withdraw a specified amount of native fees from the contract. It first checks that the amount requested is not greater than the total accrued native fees, and then calls the uln.withdrawNative() function to transfer the specified amount of native fees to the specified address. (autogenerated documentation)
validateTransactionProofV2(uint16,address,bytes32,bytes32,address) :
This function is used to validate a transaction proof on the Ethereum blockchain. It takes in a source chain ID, destination address, gas limit, block hash, data, and transaction proof as parameters. It then calls the address provided in the _to parameter with the value of msg.value. If the call fails, it emits an event indicating that the value transfer failed. Finally, it calls the uln.validateTransactionProof function to validate the transaction proof. (autogenerated documentation)
validateTransactionProofV1(uint16,address,bytes32,bytes32) :
This function is used to validate a transaction proof from a source chain to a destination address on a different chain. It takes in the source chain ID, the destination address, the gas limit, the block hash, the data, and the transaction proof as parameters. It then calls the validateTransactionProof function from the Universal Linker Network (uln) contract, which verifies that the transaction proof is valid and that the transaction was successful. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i layer-zero-relayer-v2
copy icon

Recent Use

🍞 0x705c downloaded

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.