Twin Documentation
  • Overview
  • Consumer
  • Developer
  • Operations
Arquitectura
    Backend ArchitectureDashboard ArchitecturePlatform ArchitectureBridge Contracts Architecture
Flujos Técnicos
Base de Datos
Local SetupConventions
powered by Zudoku
Arquitectura

Bridge Contracts Architecture

Hardhat v2 + Foundry project implementing LayerZero V2 OFT (Omnichain Fungible Token) for cross-chain bridging.

{% hint style="info" %} This project lives on the master branch (not main). {% endhint %}

Tech Stack

  • Hardhat v2 for compilation and deployment scripts
  • Foundry for testing (not installed locally -- CI only)
  • LayerZero V2 OFT standard
  • Solidity 0.8.x

OFT Concept

LayerZero's OFT standard enables tokens to be natively bridged across chains without wrapped representations. The token contract itself handles lock/burn on the source chain and mint/unlock on the destination chain.

The adapter contracts handle the LayerZero messaging. Each chain has a token contract and an adapter. When a user bridges from Base to Polygon:

  1. Tokens are locked/burned on Base via the adapter
  2. LayerZero relays the message to Polygon
  3. Tokens are minted/unlocked on Polygon via the adapter

Supported Chains

ChainLayerZero Endpoint IDUsage
Base30184Primary chain
Polygon30109Secondary chain

Bridge Routes

Bridge routes are configured in the backend database (bridge_route table), not in the contracts. Each route maps:

  • bridge_token_key -- Logical token identifier (e.g., ARGT)
  • ops_token_id -- Reference to the token on a specific network
  • network -- Chain where this route endpoint exists
  • adapter_address -- OFT adapter contract address on that chain
  • lz_eid -- LayerZero endpoint ID for that chain

A token like ARGT has two routes (one per chain) grouped by the same bridge_token_key.

Local Development

Foundry is not installed locally. Use Hardhat for compilation:

TerminalCode
cd twin-bridge npx hardhat compile

For Foundry-based tests, use CI or install Foundry separately:

TerminalCode
curl -L https://foundry.paradigm.xyz | bash foundryup forge test

Deployment

Deployment scripts are in scripts/. Each chain requires a separate deployment with the correct LayerZero endpoint configuration. After deploying, the adapter addresses must be registered in the backend bridge_route table for the dashboard and platform to use them.

Last modified on May 12, 2026
Platform ArchitectureFlujos Técnicos
On this page
  • Tech Stack
  • OFT Concept
  • Supported Chains
  • Bridge Routes
  • Local Development
  • Deployment