Overview
This step-by-step guide shows how to integrate LayerZero V2 with Sei. By the end of the guide, you will know how to create, deploy, and manage omnichain tokens. These tokens can move between Sei and any other LayerZero-supported blockchain.What this guide covers
- Core concepts and architecture of LayerZero
- Creating a LayerZero-enabled project from scratch
- Building an Omnichain Fungible Token (OFT), with detailed explanations
- Deploying and configuring the contracts on Sei and other chains, step by step
- Creating tasks and scripts for cross-chain token transfers
Prerequisites
- Basic knowledge of Solidity and smart contracts
- Node.js and npm installed
- A wallet with SEI and other chain tokens for gas
- Familiarity with Hardhat or Foundry
What is LayerZero?
LayerZero is an omnichain interoperability protocol for secure, permissionless communication between different blockchains. Think of it as a universal translator that lets blockchains talk to each other.Core concepts
- Endpoints: Immutable smart contracts on each blockchain that are the entry and exit points for messages
- Messages: Data packets, sent between blockchains, that contain instructions or information
- Security Stack: A customizable verification system that makes sure messages are authentic
- Omnichain Applications: Smart contracts that can operate across multiple blockchains
Key applications
- Omnichain Fungible Tokens (OFT): Tokens that exist on multiple chains with a unified supply
- Omnichain NFTs (ONFT): NFTs that can move between blockchains
- Cross-chain DeFi: Protocols that operate across multiple networks
- Unified governance: DAOs that function across chains
- Message passing: Send arbitrary data between blockchains
Sei network information
Sei Mainnet configuration
- Network Name: SEI EVM
- Chain ID: 1329
- RPC URL: https://evm-rpc.sei-apis.com
- Explorer: https://seiscan.io
- Currency: SEI
- LayerZero Endpoint ID: 30280
Contract deployments
These are the addresses of the official LayerZero V2 protocol contracts on Sei networks.Sei Mainnet (EID: 30280) — protocol contracts
Sei Mainnet (EID: 30280) — protocol contracts
Sei Mainnet — DVNs (decentralized verifier networks)
Sei Mainnet — DVNs (decentralized verifier networks)
Sei Testnet (EID: 40455) — protocol contracts
Sei Testnet (EID: 40455) — protocol contracts
Step 1: Project setup
Project scaffold
LayerZero’s CLI lets you create an OFT workspace in seconds:Add private keys
Rename the.env.example file to .env. Then add the configuration values that you need:
.env
PRIVATE_KEY. RPC URLs are optional, but strongly recommended. If you do not set them, the project uses public RPCs. Public RPCs can be unreliable or slow. Your transactions can then take a long time to confirm or, at worst, fail.
Step 2: Configure networks
Hardhat network config
Inhardhat.config.ts, add the networks that you want to deploy your contracts to:
hardhat.config.ts
LayerZero wiring config
Inlayerzero.config.ts, add the chains and the channel security settings that you want for each connection:
layerzero.config.ts
Review LayerZero’s Channel Security Model to understand the impact of each of these configuration settings.To review the available providers and security settings, see Next steps.
Step 3: Create utility tasks
Before you deploy, create a utility task that mints tokens. You need this task later.Create minting task
Createtasks/mint.ts:
tasks/mint.ts
Update Hardhat configuration
Update yourhardhat.config.ts file to import the mint task:
hardhat.config.ts
Step 4: Smart contract development
The token contract
The OFT contract handles all cross-chain logic automatically. When you send tokens:
- Source chain: Burns the tokens from the sender’s balance
- LayerZero protocol: Verifies and relays the message
- Destination chain: Mints equivalent tokens to the recipient
contracts/MyOFT.sol
Understanding OFT functions
Your contract inherits these main functions from the OFT contract:Step 5: Deployment process
Deploy
Step 6: Wire the contracts
After deployment, connect the contracts:Connect the chains
Verify configuration
Verify the peers:Step 7: Mint initial tokens
Before you transfer, you need tokens to send. Mint some tokens on Sei:Step 8: Transfer tokens cross-chain
Calling send
The OFT contract already defines thesend logic, so this section shows how to call the function.
Option 1: Hardhat task
Createtasks/sendOFT.ts:
tasks/sendOFT.ts
hardhat.config.ts file:
Option 2: Foundry script
Createscript/SendOFT.s.sol:
script/SendOFT.s.sol
Step 9: Done!
You issued an omnichain token and bridged it from Sei Mainnet to Optimism. To customize the supply logic or fees, or to add more chains, change the core contract. Then redeploy it and repeat the wiring step.Track your transaction
- Go to https://layerzeroscan.com/tx/YOUR_TX_HASH
- The page shows:
- Source transaction
- Message status
- Destination transaction
- Time elapsed
- Check the balances on both chains to confirm the transfer
Troubleshooting
Common issues and solutions
Quote send revertsIf your Check that your source configuration has a valid send library, DVN address, and target EID.2. No default pathway:Treat the LayerZero default settings as placeholders. Sometimes the LayerZero defaults contain a After you update your config, retry your
quoteSend call reverts, there are two usual causes. Your LayerZero wiring is not fully configured, or there is no default pathway for the chains that you are trying to bridge. Diagnose and fix the problem as follows:1. Wiring did not succeed:Run this command to inspect your on-chain wiring configuration:LzDeadDVN. These entries show that a default pathway setting does not exist.- Check: To see if your configuration contains a LzDeadDVN, open the Default Config Checker on LayerZero Scan.
-
Fix: Open your
layerzero.config.tsfile. Under the relevantpathwaysentry, add working DVN providers in the[ requiredDVN[], [ optionalDVN[], threshold ] ]section. - Run the wiring command for the connections again so that the wiring is live on both chains.
quoteSend flow. It should now return a fee estimate instead of reverting.Next steps
- Add more chains, such as Arbitrum, Base, and Polygon.
- Implement advanced features, such as rate limiting, pausable transfers, and fee collection.
- Use composed messages to run actions after the tokens arrive.
- Build a frontend UI that makes transfers easy.
Learn more
- To learn more about how to manage your OFTs across the entire network mesh, see the Configuring Pathways section.
- To choose which DVNs and executor to configure, see Available DVNs and Executor.
- To learn how the protocol works, read the Core Concepts section.
- To learn more about how the OFT contract works on the EVM, read the OFT Quickstart in the EVM section.
Resources
- LayerZero documentation: https://docs.layerzero.network/v2
- LayerZero Scan: https://layerzeroscan.com/
- Sei explorer: https://seiscan.io
Summary
In this guide, you:- Created an Omnichain Fungible Token project
- Configured networks and LayerZero pathways
- Deployed contracts to multiple chains
- Connected the deployments through LayerZero wiring
- Created tasks for cross-chain token transfers
- Learned how LayerZero enables omnichain applications