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

LayerZero PingPong

Audited

LayerZero Example. PingPong sends a LayerZero message back and forth between chains until stopped!

*Visit desktop site to download or deploy

Version

1.0.0

Creator

LayerZero

Recent Use

🍞 0xD044 downloaded

Last Publish

11/25/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
disable() :
This function disables the ability to send pings by setting the boolean variable pingsEnabled to false. This will prevent any further pings from being sent. (autogenerated documentation)
ping(uint16,address) :
This function is used to send a ping message to a specified address on a different blockchain. It takes three parameters: the destination chain ID, the destination address, and the number of pings. It first checks that the balance of the contract is greater than 0, that pings are enabled, and that the maximum number of pings has not been reached. It then emits a Ping event with the number of pings. It then calculates the message fee for the ping and checks that the contract has enough balance to cover the fee. Finally, it sends the ping message to the specified address on the destination chain, including the payload (the number of pings) and the adapter parameters. (autogenerated documentation)
lzReceive(uint16,uint64,) :
This function is an override of the lzReceive function from the Loomz SDK. It is used to receive data from other chains. It takes in the source chain ID, the address of the sender, a uint64, and a payload as parameters. The function first checks that the sender is the endpoint address. It then decodes the payload to get the number of pings. It then increments the number of pings and stores it in the numPings variable. Finally, it calls the ping function to send the updated number of pings back to the sender. (autogenerated documentation)
setConfig(uint16,,uint16) :
This function sets a configuration for a given chain ID. It takes in four parameters: a uint16, a uint16 _dstChainId, a uint _configType, and a bytes memory _config. The function calls the setConfig() function from the endpoint contract, passing in the _dstChainId, the send version of the current contract, the _configType, and the _config. This allows the configuration to be set for the given chain ID. (autogenerated documentation)
getConfig(uint16,,uint16) :
This function is used to retrieve a configuration from the endpoint contract. It takes four parameters: a uint16, a uint16 chainId, an address, and a uint configType. It then calls the getConfig function from the endpoint contract, passing in the send version of the address of the current contract, the chainId, the address of the current contract, and the configType. The function then returns a bytes memory containing the configuration. (autogenerated documentation)
setSendVersion(uint16) :
This function sets the version of the endpoint that will be used when sending messages. It works by calling the setSendVersion() function on the endpoint object, passing in the version number as an argument. (autogenerated documentation)
setReceiveVersion(uint16) :
This function sets the version of the receive protocol for the endpoint. It works by calling the setReceiveVersion() function on the endpoint, passing in the version number as an argument. This function is typically used to ensure that the endpoint is using the most up-to-date version of the receive protocol. (autogenerated documentation)
getSendVersion() :
This function retrieves the version of the endpoint associated with the current contract. It does this by calling the getSendVersion() function from the endpoint contract, passing in the address of the current contract as an argument. The function returns a uint16 value representing the version of the endpoint. (autogenerated documentation)
getReceiveVersion() :
This function gets the version of the contract that is currently being received by the contract. It works by calling the getReceiveVersion() function from the endpoint contract, passing in the address of the current contract as an argument. The function then returns the version of the contract that is currently being received. (autogenerated documentation)
forceResumeReceive(uint16) :
This function is used to force a resume of a receive operation on a given source chain and address. It works by allowing the caller to specify the source chain ID and address of the receive operation they wish to resume. The function then checks the validity of the parameters and resumes the receive operation. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i layerzero-pingpong
copy icon

Recent Use

🍞 0xD044 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.