Skip to content

onflow/flow-bridge-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flow Bridge - LayerZero OFT Implementations

Repository containing LayerZero Omnichain Fungible Token (OFT) implementations for cross-chain token bridging between EVM chains and Flow blockchain.

Token Bridging Flow

┌─────────────────────────────────────────────────────────────────────────────────┐
│                         Flow Token Bridge                                │
└─────────────────────────────────────────────────────────────────────────────────┘

═══════════════════════════════════════════════════════════════════════════════════
  SCENARIO 1: EVM to Flow (Lock & Mint)
═══════════════════════════════════════════════════════════════════════════════════

  EVM Chain                    LayerZero Protocol                Flow Chain
  ─────────                    ──────────────────                ──────────

  ┌──────────┐
  │   User   │
  │(Ethereum)│
  └────┬─────┘
       │ 1. send()
       ▼
  ┌──────────┐
  │   OFT    │
  │ Adapter  │──────┐
  │  LOCK    │      │ 2. Emit
  │ Tokens   │      │    Message
  └──────────┘      │
                    ▼
              ╔════════════════╗
              ║   LayerZero    ║
              ║   Messaging    ║      3. Relay
              ║   Layer (DVNs  ║─────────────────────┐
              ║   & Oracles)   ║                     │
              ╚════════════════╝                     │
                                                     ▼
                                                ┌──────────┐
                                                │   OFT    │
                                                │ Contract │
                                                │   MINT   │
                                                │  Tokens  │
                                                └────┬─────┘
                                                     │ 4. Transfer
                                                     ▼
                                                ┌──────────┐
                                                │   User   │
                                                │ on Flow  │
                                                └──────────┘

═══════════════════════════════════════════════════════════════════════════════════
  SCENARIO 2: Flow to EVM (Burn & Unlock)
═══════════════════════════════════════════════════════════════════════════════════

  Flow Chain                   LayerZero Protocol                EVM Chain
  ──────────                   ──────────────────                ─────────

  ┌──────────┐
  │   User   │
  │ on Flow  │
  └────┬─────┘
       │ 1. send()
       ▼
  ┌──────────┐
  │   OFT    │
  │ Contract │──────┐
  │   BURN   │      │ 2. Emit
  │  Tokens  │      │    Message
  └──────────┘      │
                    ▼
              ╔════════════════╗
              ║   LayerZero    ║
              ║   Messaging    ║      3. Relay
              ║   Layer (DVNs  ║─────────────────────┐
              ║   & Oracles)   ║                     │
              ╔════════════════╝                     │
                                                     ▼
                                                ┌──────────┐
                                                │   OFT    │
                                                │ Adapter  │
                                                │  UNLOCK  │
                                                │ Tokens   │
                                                └────┬─────┘
                                                     │ 4. Transfer
                                                     ▼
                                                ┌──────────┐
                                                │   User   │
                                                │(Ethereum)│
                                                └──────────┘

Bridging Process:

EVM to Flow (Lock & Mint):

  1. Source Chain (EVM): User calls send() on OFT Adapter, tokens are locked in the adapter contract
  2. LayerZero Protocol: Message is encoded and sent through LayerZero's decentralized network of verifiers (DVNs) and oracles
  3. Destination Chain (Flow): OFT contract receives verified message and mints equivalent tokens on Flow EVM
  4. Result: User receives newly minted tokens on Flow with 1:1 parity

Flow to EVM (Burn & Unlock):

  1. Source Chain (Flow): User calls send() on Flow OFT contract, tokens are burned
  2. LayerZero Protocol: Message is relayed back through the decentralized network
  3. Destination Chain (EVM): OFT Adapter receives message and unlocks the original tokens
  4. Result: User receives unlocked tokens on the EVM chain, maintaining 1:1 parity

Project Structure

This repository contains multiple implementations for cross-chain token bridging:

ethereum-oapp/

EVM LayerZero OFT Implementation

A comprehensive LayerZero OFT (Omnichain Fungible Token) implementation for EVM-compatible blockchains. This directory contains:

  • Smart Contracts: Multiple OFT contract implementations (MyOFT.sol, MyOFTAdapter.sol, MyOFTFungi.sol, etc.)
  • Deployment Scripts: Hardhat-based deployment and configuration tools
  • Testing: Both Hardhat and Foundry test suites
  • Configuration: LayerZero network configurations for multiple EVM chains
  • Custom Scripts: Token transfer utilities for EVM-to-EVM and EVM-to-Flow bridging

Key Features:

  • Multi-chain deployment support (Ethereum, Arbitrum, Base, Avalanche, etc.)
  • LayerZero DevTools integration with helper tasks
  • Cross-chain configuration management
  • Token minting and burning mechanisms
  • OFT transfer scripts with environment variable support

Supported Networks:

  • Testnets: Sepolia, Base Sepolia, Arbitrum Sepolia, Avalanche Fuji
  • Mainnets: Ethereum, Flow, Arbitrum, Base, Avalanche

solana-oapp/

Solana LayerZero OFT Implementation

A complete Solana-based OFT implementation using Anchor framework for cross-chain token bridging. This directory contains:

  • Programs: Solana programs written in Rust (oft/, endpoint-mock/)
  • Anchor Framework: Complete Anchor project setup with tests
  • Deployment Tools: Solana CLI deployment scripts and utilities
  • Configuration: LayerZero configuration for Solana networks
  • Tasks: Hardhat tasks for Solana OFT operations

Key Features:

  • Solana program deployment and management
  • SPL token integration with OFT standard
  • Cross-chain messaging with LayerZero
  • Mint authority multisig support
  • Token creation and transfer utilities

Requirements:

  • Rust 1.75.0, Anchor 0.29, Solana CLI 1.17.31
  • Docker for program builds
  • Node.js for deployment scripts

Supported Networks:

  • Solana Devnet/Testnet and Mainnet-beta
  • Cross-chain compatibility with EVM networks

web-app/

Flow Bridge Web Interface

A Next.js web application that provides a user-friendly interface for cross-chain token bridging and swapping. This application integrates the LI.FI Widget to enable seamless token transfers across multiple blockchain networks.

Purpose: The web app serves as a frontend interface for users to bridge tokens between different blockchain networks without needing to interact directly with smart contracts or command-line tools. It leverages LI.FI's aggregation layer to find the best routes for cross-chain transfers across multiple bridge protocols including LayerZero.

Key Features:

  • Simple, intuitive web interface for cross-chain token transfers
  • Integration with LI.FI Widget for access to multiple bridge protocols
  • Support for connecting various wallet providers (MetaMask, WalletConnect, etc.)
  • Real-time bridge route optimization and fee estimation
  • Responsive design for desktop and mobile devices
  • Built with Next.js 14 and TypeScript for optimal performance

Technology Stack:

  • Next.js 14 (App Router)
  • React 18
  • TypeScript
  • LI.FI Widget SDK
  • Deployed on Vercel

Use Cases:

  • Bridge tokens from Ethereum to Flow and other EVM chains
  • Swap and bridge in a single transaction
  • Compare bridge routes and select optimal paths
  • Monitor cross-chain transaction status

For detailed setup and deployment instructions, see the Web App README.

Technologies Used

  • LayerZero: Omnichain communication protocol
  • Solidity: Smart contract development
  • Rust/Anchor: Solana program development
  • Hardhat/Foundry: EVM development and testing
  • TypeScript: Type-safe development

Getting Started

Prerequisites

  1. For EVM Development:

    • Node.js and npm/pnpm
    • Hardhat and Foundry
    • Private keys for deployment networks
  2. For Solana Development:

    • Rust toolchain
    • Anchor framework
    • Solana CLI tools
    • Docker

Quick Start

  1. Clone the repository:

    git clone <repository-url>
    cd flow-bridge-app
  2. Choose your implementation:

    • For Web Interface: Navigate to web-app/ (user-facing bridge application)
    • For EVM chains: Navigate to ethereum-oapp/ (smart contract development)
    • For Solana: Navigate to solana-oapp/ (Solana program development)
  3. Follow the setup instructions in each directory's README:

Development Workflow

Deploying Contracts

EVM Networks:

cd ethereum-oapp
npx hardhat lz:deploy

Solana:

cd solana-oapp
solana program deploy --program-id target/deploy/oft-keypair.json target/verifiable/oft.so -u devnet

Configuring Flow Connections

EVM Networks:

npx hardhat lz:oapp:wire --oapp-config layerzero.config.ts

Solana:

npx hardhat lz:oapp:wire --oapp-config layerzero.config.ts --solana-secret-key <PRIVATE_KEY>

Transferring Tokens

EVM to EVM:

npx hardhat oft:send --from-chain ethereum-mainnet --to-chain flow-mainnet --amount 1.5 --receiver <ADDRESS>

EVM to Solana:

npx hardhat --network sepolia-testnet send --dst-eid 40168 --amount <AMOUNT> --to <ADDRESS>

Solana to EVM:

npx hardhat lz:oft:solana:send --amount <AMOUNT> --from-eid 40168 --to <ADDRESS> --to-eid 40161

Deployed Contract Addresses

EVM Testnets

Sepolia Testnet

Arbitrum Sepolia Testnet

Avalanche Fuji Testnet

EVM Mainnets

Ethereum Mainnet

Flow Networks

Flow Testnet

Flow Mainnet

Solana Networks

Solana Devnet/Testnet

Solana Mainnet

Documentation

For detailed information about each implementation:

Contributing

Please refer to the individual README files in each subdirectory for specific contribution guidelines and development practices.

License

This project is licensed under the terms specified in the individual contract implementations.

About

Bridge to allow users to bridge to and from evm on Flow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •