Skip to main content

Overview

This guide provides a comprehensive, step-by-step tutorial for integrating LayerZero V2 with the SEI blockchain. By the end of this guide, you will understand how to create, deploy, and manage omnichain tokens that can seamlessly move between SEI and any other LayerZero-supported blockchain.

What This Guide Covers

  • Understanding LayerZero: Core concepts and architecture
  • Project Setup: Creating a LayerZero-enabled project from scratch
  • Smart Contracts: Building an Omnichain Fungible Token (OFT) with detailed explanations
  • Deployment & Configuration: Step-by-step deployment to SEI and other chains
  • Cross-Chain Transfers: Creating tasks and scripts for 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 that enables secure, permissionless communication between different blockchains. Think of it as a universal translator that allows blockchains to talk to each other.

Core Concepts

  • Endpoints: Immutable smart contracts deployed on each blockchain that serve as entry/exit points for messages
  • Messages: Data packets sent between blockchains containing instructions or information
  • Security Stack: Customizable verification system ensuring message authenticity
  • Omnichain Applications: Smart contracts that can operate across multiple blockchains

Key Applications

  • Omnichain Fungible Tokens (OFT): Tokens that exist across multiple chains with 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

The following are the official LayerZero V2 protocol contract addresses deployed on Sei networks.

Step 1: Project Setup

Project scaffold

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

Add private keys

Rename .env.example file to .env and update it with needed configurations:
.env
At a minimum, you need to have the PRIVATE_KEY. RPC URLs are optional, but strongly recommended. If you don’t provide them, public RPCs will be used, but public RPCs can be unreliable or slow, leading to long waiting times for transactions to be confirmed or, at worst, cause your transactions to fail.

Step 2: Configure Networks

Hardhat network config

Update your hardhat.config.ts file to include the networks you want to deploy your contracts to:
hardhat.config.ts

LayerZero wiring config

Modify your layerzero.config.ts file to include the chains and channel security settings you want for each connection:
layerzero.config.ts
It is strongly recommended to review LayerZero’s Channel Security Model and understand the impact of each of these configuration settings.See Next Steps to review the available providers and security settings.

Step 3: Create Utility Tasks

Before deployment, let’s create a utility task for minting tokens that we’ll need later.

Create Minting Task

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

Update Hardhat Configuration

Now update your hardhat.config.ts to import the mint task:
hardhat.config.ts
Important: You must create and import the mint task before deployment, otherwise Hardhat will throw an error when trying 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 tokens are sent:
  1. Source Chain: Burns tokens from sender’s balance
  2. LayerZero Protocol: Verifies and relays the message
  3. Destination Chain: Mints equivalent tokens to recipient
contracts/MyOFT.sol
The OFT contract uses the ERC20 token standard. You may want to add a mint(...) function in the constructor(...) or contract body if this is your first time deploying an OFT. If you have an existing ERC20 token, you will want to use an OFT Adapter contract.You can read the general OFT Quickstart for a better understanding of how OFTs work and what contracts to use.

Understanding OFT Functions

Key inherited functions from the OFT contract:

Step 5: Deployment Process

Deploy

You will be presented with a list of networks to deploy to.
Fund your deployer with native gas tokens beforehand.

Step 6: Wire the Contracts

After deployment, contracts need to be connected:

Connect the chains

Verify Configuration

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

Step 7: Mint Initial Tokens

Before transferring, you need tokens to send. Let’s mint some tokens on SEI:

Step 8: Transfer Tokens Cross-Chain

Calling send

Since the send logic has already been defined, we’ll instead view how the function should be called.

Option 1: Hardhat Task

Create tasks/sendOFT.ts:
tasks/sendOFT.ts
Don’t forget to import the task in your hardhat.config.ts (if not already added):
Execute the transfer:

Option 2: Foundry Script

Create script/SendOFT.s.sol:
script/SendOFT.s.sol
Environment Setup:

Step 9: Done!

You’ve issued an omnichain token and bridged it from Sei Mainnet to Optimism. Customize supply logic, fees, or add more chains by applying changes to the core contract, redeploying, and repeating the wiring step.

Track Your Transaction

  1. Visit https://layerzeroscan.com/tx/YOUR_TX_HASH
  2. You’ll see:
    • Source transaction
    • Message status
    • Destination transaction
    • Time elapsed
  3. Check balances on both chains to confirm the transfer

Troubleshooting

Common Issues and Solutions

Quote Send RevertsIf your quoteSend call reverts, it usually means that your LayerZero wiring hasn’t been fully configured or there’s no default pathway for the chains you’re trying to bridge. Here’s how to diagnose and fix it:1. Wiring Didn’t Succeed:Run the following to inspect your on‑chain wiring configuration:
See that your source configuration has a valid send library, DVN address, and target eid.2. No Default Pathway:LayerZero default settings should be considered placeholders. Sometimes the LayerZero defaults will contain a LzDeadDVN. Those entries indicate that a default pathway setting does not exist.
  • Check: You can see if your configuration contains a LzDeadDVN by viewing the Default Config Checker on LayerZero Scan.
  • Fix: Open your layerzero.config.ts and under the relevant pathways entry, add working DVN providers (in the [ requiredDVN[], [ optionalDVN[], threshold ] ] section).
  • Re-run your wiring command for the connections so that the wiring on both chains is live.
Once you’ve updated 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 like this:

Next Steps

  • Add More Chains: Expand to Arbitrum, Base, Polygon, etc.
  • Advanced Features: Implement rate limiting, pausable transfers, fee collection
  • Composed Messages: Execute actions after token arrival
  • Build a UI: Create a frontend for easy transfers

Learn More

Resources

Summary

You’ve successfully:
  • ✅ Created an Omnichain Fungible Token project
  • ✅ Configured networks and LayerZero pathways
  • ✅ Deployed contracts to multiple chains
  • ✅ Connected the deployments via LayerZero wiring
  • ✅ Created tasks for cross-chain token transfers
  • ✅ Learned how LayerZero enables omnichain applications
Your tokens can now move freely between SEI and any connected chain, maintaining a unified supply and enabling true cross-chain functionality!