What is LayerZero and How it works
LayerZero is an omnichain interoperability protocol designed for lightweight messages passing across chains. LayerZero provides authentic and guaranteed message delivery with configurable trustlessness.
Messages in LayerZero are sent and received by LayerZero Endpoints, which handle message transmission, verification, and receipt; these endpoints consist of two components: a collection of versioned messaging libraries, and a proxy to route messages to the correct library version. When a message arrives at an endpoint, the endpoint selects the User Application configured library version to handle the message. The endpoint keeps all message states across versions and this allows libraries to be easily upgraded for fixes or optimizations.
How LayerZero Works
User Application (UA)
The user application (UA) represents the smart contract containing business logic and interfacing with LayerZero.
Messages are sent unicast exclusively.
As you can see from the example code, to integrate with LayerZero, you have to override the _nonblockingLzReceive method to receive messages and call _lzSend to send to the destination blockchain.
TrustedRemote
For security reasons, a contact can receive messages only from known contracts, so they must be interfaced with a Trusted Remote Contract after the User Applications are deployed.
A Trusted Remote is another contract that only forwards messages to the destination from an authorized source.
https://github.com/LayerZero-Labs/set-trusted-remotes
Oracle
The oracle is the component responsible for transferring data from one chain to another.
Relayer
The relayer cooperates with the oracle, but instead of transferring the transaction header, it checks for proof of the transaction.
Thanks to this approach, it is possible to guarantee the resilience of the protocol and the security of transfers.
Protocol adoption
As a protocol under development, collaborations may vary from what is reported below. (Updated to 28/10/2022)
- Mainnet
- Ethereum
- BNB Chain
- Avalanche
- Aptos
- Polygon
- Arbitrum
- Optimism
- Fantom
- Swimmer
- DFK
- Harmony
- Moonbeam
Testnet
- Goerli (Ethereum Testnet)
- BNB Chain (Testnet)
- Fuji (Avalanche Testnet)
- Aptos (Testnet)
- Mumbai (Polygon Testnet)
- Fantom (Testnet)
- Arbitrum-Goerli (Testnet)
- Optimism-Goerli (Testnet)
- Harmony (Testnet)
- Moonbeam (Testnet)
- Celo (Testnet)
- Dexalot (Testnet)
- Portal Fantasy (Testnet)
Pontem bridge
A mainnet implementation of LayerZero is going to be implemented by the Pontem team. It will allow the bridge between Aptos and EVM.
References
LayerZero whitepaper [https://layerzero.network/pdf/LayerZero_Whitepaper_Release.pdf]
LayerZero documentation, [https://layerzero.gitbook.io/docs/]