Interoperability between blockchains is a prevalent problem in the current landscape and one without a simple solution. Isolation between ecosystems has emerged as a key limit to adoption and having an efficient and safe solution would be of great benefit to the industry as a whole. Bridges have been commonly used but often use smart contracts that wrap tokens, rather than bridging tokens natively. Bridges have also been subject to a whopping $2B in hacks thus far in 2022 and as such have severe security risks.
Below I will provide an overview of LayerZero and its unique architecture, and how LayerZero Endpoints can be used to communicate between blockchains directly, securely, and affordably.
Background on LayerZero
LayerZero is a Vancouver, Canada-based blockchain startup that raised a whopping $135M USD in March 2022, valuing them in excess of $1B. It was co-led by some of the biggest names in Venture Capital including Sequoia Capital, FTX Ventures, and Andreesen Horowitz, with participation from a wide variety of other reputable VC firms including Tiger Capital and Uniswap Labs.
Apart from LayerZero, they’ve also launched Stargate which is a cross-chain liquidity protocol built upon their messaging system. At the time of writing, Stargate’s total value locked (TVL) is at $540M, having peaked at $4B in April 2022.
LayerZero was co-founded in 2021 by Bryan Pellegrino (CEO), Ryan Zarick (CTO), and Caleb Banister (Principal Engineer). The three co-founders all have entrepreneurial backgrounds and worked on a series of projects together prior, such as Coder Den, 80Trill, and Minimal AI. Despite only being around a short time, they’ve already have tremendous success and have grown to ~27 people at the time of writing.
Why is LayerZero Needed?
In the LayerZero whitepaper, the three co-founders provide an overview of LayerZero, which they describe as the first trustless omnichain interoperability protocol. It is a low-level communication primitive that acts as a building layer for cross-chain applications, without requiring an intermediary or trusted custodian.
Basically, it’s a low-level method of direct communication between blockchains. I’ll explain what this entails!
LayerZero breaks down current interoperability solutions into:
- Centralized exchanges (CEX’s): Binance and others have deep liquidity networks that enable them to perform swapping between blockchains for users. This requires a user to deposit assets from a given blockchain, convert assets on the platform, and then withdraw onto their new chain of desire. However, this goes against the fundamental principle of centralization, and numerous hacks have occurred as detailed here.
- Decentralized exchanges (DEX’s): Anyswap and THORChain are examples of on-chain decentralized exchanges whereby a user swaps their token into an intermediate token (e.g. RUNE in the case of THORChain) and then can swap it again to their desired token. This additional step makes the transfer indirect and inefficient.
This is only one way amongst many of separating existing interoperability solutions. For example, research paper Blockchain Interoperability: Towards a Sustainable Payment System separates existing solutions as:
a) Side Chains (e.g. RSK)
b) Industrial Solutions: those built for specific applications (e.g. Cosmos)
c) Notary Scheme (e.g. a CEX like Binance)
It’s also worth noting that many interoperability protocols exist but LayerZero is referring to native token interoperability, in contrast to cross-chain wrapping whereby wrapped tokens are created via smart contracts. Native tokens are the actual tokens from the blockchain (e.g. Ether on Ethereum) whereas wrapped tokens are representations of an asset on its non-native chain (e.g. ERC-20 Bitcoin on Ethereum). Wrapping is easier but involves more steps and as such is less scalable, while being more susceptible to security issues as well.
For a detailed overview of native vs. wrapped, check out this article here on multichain vs cross-chain.
As blockchain usage scales globally, having an efficient, safe, and direct manner of interacting cross-chain is critical. While both CEX’s and DEX’s may work, they have drawbacks mentioned above. It’s also worth noting they are examples of applications built ON TOP OF blockchains, whereas LayerZero is a communication primitive enabling omnichain applications to benefit from its technology.
How does it work?
Let’s imagine that we have Blockchain A and Blockchain B. Imagine that Blockchain A would like to send a message m to Blockchain B via transactionA. For this message to be delivered, transactionA must be both committed and valid.
The key idea of LayerZero is that it’s possible to agree on a message being both valid and committed if we use two independent entities who each agree on its validity.
This is shown below (don’t worry, I’ll explain):
The two independent parties designated to agree on a given transaction’s validity are:
- An Oracle: these are 3rd parties that enable blockchains to access external, real-world data. LayerZero tends to use ChainLink, the most popular framework for building and connecting to decentralized oracle networks (DONs). For an explanation on Oracles, check out Gemini’s description here which is an easier read than Chainlink’s 137-page whitepaper.
- A Relayer: an off-chain service similar to an Oracle, but handled by a 3rd party or LayerZero.
The Oracle is meant to confirm a given block’s header, while the Relayer is meant to confirm a given transaction’s proof. If the transaction is proved as valid and corresponds to the block, then it is considered valid.
LayerZero — Steps 1–7
Steps 1–5: A user application sends a request to LayerZero Endpoint with information such as a transaction identifier (“t”), smart contract identifier for Blockchain B (“dst”), any data wished to be sent (“payload”), and additional Relayer arguments (“relayer_args”).
The Relayer is notified that it will need to fetch transaction proof, and the Oracle is notified that it will need to fetch the block header for the current block on Blockchain A, and send it to Blockchain B.
Remember, there are the roles of the Relayer and Oracle, and they should remain independent in order to confirm that a transaction is valid and corresponds to the correct block.
Steps 6–7: The Oracle and Relayer actually read the block header and transaction proof.
LayerZero — Steps 8–12
Steps 8–11: First, the Oracle confirms that the relevant block was committed onto Blockchain A without issues (e.g. after a certain amount of block confirmations) and sends this to Blockchain B’s Network. The corresponding block hash is sent to the Validator, and subsequently sent to the Relayer. The Relayer receives the block hash and sends back any “Packets” that match that given block (in the event that multiple LayerZero messages were sent in a given block, multiple transactions proofs can be sent at once).
Steps 12–13: The Validator confirms that the transaction proof (received by the Relayer) does in fact correspond to the block header (received by the Oracle). The Packet is then sent to the user application on Blockchain B.
The Importance of Independence
Given that the Oracle and Relayer are independent it is statistically impossible that they can collude. Consider that a given hash consists of 256 bytes (it can vary by hashing method used but this is an example), meaning there are 2 ^ 256 possible combinations. This means that they would have to collude which is not possible, as long as they do in fact remain independent. Therefore, by validating that a block header and transaction proof match, a trustless guarantee is formed.
The LayerZero team highlights a few potential use-cases of LayerZero implementation:
- Cross-chain DEX’s: this could create massive efficiencies for the swapping of cross-chain native assets while enabling efficient programmability of protocols such as customizable AMM’s.
- Multi-chain yield aggregator: enables one to take advantage of yield opportunities across numerous other blockchains to find the best opportunities.
- Multi-chain lending: enables users to take advantage of other chains where they do not have assets. Right now one would have to transfer assets over to another chain, for example using a bridge (which have been subject to $2B in hacks thus far in 2022).
Considering that the TVL of DeFi at the moment is ~$60B and only expected to grow, having greater cross-chain efficiency that both reduces hacks and increases efficiency is very important.
LayerZero will reduce barriers between siloed blockchain ecosystems, enabling the fast and frictionless transfer of value and information between various blockchains and communities of Web3.
This will help speed up the technological advancements and adoption of blockchain, and it’s no wonder that the top VC’s have all invested in LayerZero. Their challenge is now becoming more efficient (e.g. they began to run ultralight nodes) and creating network efforts across various blockchains and protocols. However, there’s a clear need for their solution and this can only be expected to grow (not financial advice).
By the way, if you liked the above or have any feedback, please let me know in the comments!