LayerZero
What is LayerZero?
LayerZero is an omnichannel interoperability protocol designed to facilitate cross-chain communication. By enabling secure and efficient message passing across chains, LayerZero allows developers to build decentralized applications (dApps) that operate cohesively over multiple blockchains. This capability enhances the functionality and user experience of dApps by leveraging the unique features of various ecosystems.
Overview of LayerZero and HTS Compatibility
LayerZero integrates seamlessly with the Hedera Token Service (HTS) and EVM-compatible tokens (ERC-20 and ERC-721). This integration enables efficient cross-chain communication for various token types, making it easier to bridge assets such as $USDC or $Sauce between Hedera and other networks.
Getting Started with LayerZero on Hedera
To get started quickly, you can begin with the Gitpod demo, which requires no environment setup. Alternatively, you can go directly into the LayerZero Quickstart series. These guides provide an overview of deploying an Omnichain Application (OApp) on Hedera and other EVM-compatible networks, covering essentials like setting up your LayerZero environment and deploying contracts for cross-chain messaging.
A no-setup-required demo to experience LayerZero
A step-by-step guide for deploying an omnichain application.
Explore examples for bridging tokens with LayerZero.
LayerZero Examples and Key Components
All examples in the demo repo are exploratory code and have NOT been audited. Please use it at your own risk!
Omnichain Fungible Token (OFT) / Omnichain Non-Fungible Token (ONFT)
The OFT and ONFT token standards allow the transfer of fungible (ERC-20s) and non-fungible tokens (ERC-721s) across chains using LayerZero's messaging infrastructure. If you're bridging an existing fungible ERC token on Hedera to another EVM chain, you can deploy the OFT standard contract and the ONFT standard contract for NFTs.
Use Case
Allows fungible and non-fungible tokens to be transferred across chains.
Example Contracts
Considerations
HTS tokens can function as ERC-compatible assets through an OFT adapter, requiring no modifications.
OFT standard token contracts must be deployed on the destination chain.
OFT Adapter / ONFT Adapter
The OFT Adapter acts as an intermediary contract that handles sending and receiving existing fungible tokens across chains. If your token already exists on the chain you want to connect to, you can deploy the OFT Adapter contract to act as an intermediary lockbox for the token. Similarly, the ONFT Adapter handles sending and receiving existing fungible tokens across chains. If your NFT already exists on the chain you want to connect to, you can deploy the ONFT Adapter contract to act as an intermediary lockbox for the NFT.
Use Case
Intermediary contract that handles sending and receiving existing fungible tokens across chains. If your token already exists on the chain you want to connect to, you can deploy the OFT Adapter contract to act as an intermediary lockbox for the token.
Example Contracts
Considerations
HTS tokens can function as ERC-compatible assets through an OFT adapter, requiring no modifications.
HTS Connector
The HTS Connector extends LayerZero’s functionality to accommodate HTS tokens, addressing the differences between HTS and ERC token standards. It facilitates the integration of existing ERC tokens with Hedera by bridging them as native HTS tokens. This is a variant of OFT when bringing tokens to Hedera as HTS. If you bring a token to Hedera as an ERC token, you can use OFT or ONFT.
Use Case
Bridging a token from other networks to Hedera as an HTS token.
Considerations:
When deploying HTS connector:
The contract should be associated to the token or be deployed with
maxAutomaticAssociation
The "supply key" of the token must contain the address of the HTS Connector contract.
Developer Considerations to Note EVM Differences
Please note the smallest unit of HBAR is the tinybar (8 decimal places), while the JSON-RPC relay operates 18 decimal places for compatibility with Ethereum tools. This means when dealing with msg.value
, conversions between tinybars and weibars are necessary. Additionally, Hedera’s gas model charges for at least 80% of gas, regardless of usage, and event handling often requires querying mirror nodes. Please take these differences into account, especially when calling quote
. Reference the Understanding Hedera's EVM Differences and Compatibility: For EVM Developers section for a more comprehensive list of differences.
Additional Resources
Last updated
Was this helpful?