Skip to main content

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

Contract deployments

These are the addresses of the official LayerZero V2 protocol contracts on Sei networks.

Step 1: Project setup

Project scaffold

LayerZero’s CLI lets you create an OFT workspace in seconds:
The wizard creates a repo with a Hardhat and Foundry setup, sample contracts, tests, and LayerZero helper scripts.

Add private keys

Rename the .env.example file to .env. Then add the configuration values that you need:
.env
At a minimum, you need the 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

In hardhat.config.ts, add the networks that you want to deploy your contracts to:
hardhat.config.ts

LayerZero wiring config

In layerzero.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

Create tasks/mint.ts:
tasks/mint.ts

Update Hardhat configuration

Update your hardhat.config.ts file to import the mint task:
hardhat.config.ts
Create and import the mint task before you deploy. Otherwise, Hardhat throws an error when it tries to resolve the task dependencies during compilation.

Step 4: Smart contract development

The token contract

The OFT contract handles all cross-chain logic automatically. When you send tokens:
  1. Source chain: Burns the tokens from the sender’s balance
  2. LayerZero protocol: Verifies and relays the message
  3. Destination chain: Mints equivalent tokens to the recipient
contracts/MyOFT.sol
The OFT contract uses the ERC-20 token standard. If this is your first time deploying an OFT, you may want to add a mint(...) function in the constructor(...) or contract body. If you have an existing ERC-20 token, use an OFT Adapter contract.To learn more about how OFTs work and which contracts to use, you can read the general OFT Quickstart.

Understanding OFT functions

Your contract inherits these main functions from the OFT contract:

Step 5: Deployment process

Deploy

The command shows a list of networks to deploy to.
Fund your deployer with native gas tokens before you deploy.

Step 6: Wire the contracts

After deployment, connect the contracts:

Connect the chains

Verify configuration

Verify the peers:
This command shows the current LayerZero wiring configuration, including the connected chains and their peer addresses.

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 the send logic, so this section shows how to call the function.

Option 1: Hardhat task

Create tasks/sendOFT.ts:
tasks/sendOFT.ts
If you have not already done so, import the task in your hardhat.config.ts file:
Send the tokens:

Option 2: Foundry script

Create script/SendOFT.s.sol:
script/SendOFT.s.sol
Set the environment variables and run the script:

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

  1. Go to https://layerzeroscan.com/tx/YOUR_TX_HASH
  2. The page shows:
    • Source transaction
    • Message status
    • Destination transaction
    • Time elapsed
  3. Check the balances on both chains to confirm the transfer

Troubleshooting

Common issues and solutions

Quote send revertsIf 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:
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 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.ts file. Under the relevant pathways entry, 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.
After you update your config, retry your quoteSend flow. It should now return a fee estimate instead of reverting.
Insufficient gasIf the transaction fails on the destination chain, try to increase the gas:

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

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
Your tokens can now move between Sei and any connected chain, and the total supply stays unified.