Skip to content

onflow/flow-bridge-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Cross-Chain 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

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 EVM chains: Navigate to ethereum-oapp/
    • For Solana: Navigate to solana-oapp/
  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 Cross-Chain 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 2

  •  
  •