Skip to main content
Security advisory: The permissionless WAB deployment configures its own DVN set at deploy time. Child bridges may have varying security assumptions. Before bridging significant value through a WAB child, users should verify the DVN configuration via endpoint.getConfig(childAddress, sendLibrary, destinationEid, 2). Configurations with fewer than 2 required DVN attestations should be treated as single-point-of-failure risk.
Use this guide when you want to bridge an existing ERC20 from another chain (e.g. Sepolia) to Berachain using LayerZero V2 and the OFT (Omnichain Fungible Token) standard.

Repository

Official documentation

Requirements

  • Node v20.11.0 or greater, npm
  • Wallet with Berachain testnet $BERA — Bepolia Faucet
  • Wallet with Sepolia $UNI (or other source token) — see README for faucet/Uniswap
  • Foundry

Stack

Solidity, Foundry (Forge scripts), Node.js, LayerZero V2 OFT.

Quick start

  1. Clone and install
    git clone https://github.com/berachain/guides.git && cd guides/apps/layerzero-oft
    npm install
    
  2. Create .env with PRIVATE_KEY, SEPOLIA_ADAPTER_ADDRESS, BERACHAIN_OFT_ADDRESS (fill addresses after deploying).
  3. Deploy adapter on Sepolia
    forge script script/MyAdapter.s.sol --rpc-url https://rpc.sepolia.org/ --broadcast
    
    Set SEPOLIA_ADAPTER_ADDRESS in .env.
  4. Deploy OFT on Berachain
    forge script script/MyOFT.s.sol --rpc-url https://bepolia.rpc.berachain.com/ --broadcast
    
    Set BERACHAIN_OFT_ADDRESS in .env.
  5. Bridge tokens
    forge script script/Bridge.s.sol --rpc-url https://rpc.sepolia.org/ --broadcast
    

Key files

PurposePath
Source chain adapterscript/MyAdapter.s.sol (and source)
Berachain OFTscript/MyOFT.s.sol (and source)
Bridge scriptscript/Bridge.s.sol