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:
- Tokens are locked/burned on Base via the adapter
- LayerZero relays the message to Polygon
- Tokens are minted/unlocked on Polygon via the adapter
Supported Chains
| Chain | LayerZero Endpoint ID | Usage |
|---|---|---|
| Base | 30184 | Primary chain |
| Polygon | 30109 | Secondary 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 networknetwork-- Chain where this route endpoint existsadapter_address-- OFT adapter contract address on that chainlz_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:
Code
For Foundry-based tests, use CI or install Foundry separately:
Code
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.