A bridge implementation for the OPEN Ticketing Ecosystem using LayerZero's Omni Fungible Token (OFT) standard to enable cross-chain token transfers between Ethereum (and testnets) and the Etherlink blockchain.
- Cross-chain token bridging using LayerZero v2 protocol
- Support for both mainnet and testnet environments
- Automated deployment and configuration scripts
- Comprehensive testing and verification tools
- TypeScript/Hardhat development environment
- Linting and code formatting enforcement
- GitHub Actions CI/CD pipeline
Before you begin, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/GETProtocol/opn-etherlink-bridge.git cd opn-etherlink-bridge
-
Install dependencies:
bun install
-
Set up environment variables:
cp .env.example .env
Edit
.env
and add your:MNEMONIC
: Your wallet's mnemonic phraseINFURA_API_KEY
: API key for InfuraETHERSCAN_API_KEY
: API key for Etherscan verification
The bridge consists of three main components:
- ERC20 Token (source chain)
- OFTAdapter (source chain)
- OFT Token (destination chain)
Use the automated setup script to deploy and configure all components:
# On source chain (e.g., Sepolia)
npx hardhat setup-bridge \
--token-name "TestOPN" \
--token-symbol "TSTOPN" \
--token-supply "2200000" \
--oft-name "TestOFT" \
--oft-symbol "TOFT" \
--test-amount "100" \
--receiver "YOUR_ADDRESS" \
--network sepolia
If you prefer to set up components individually:
-
Deploy Token (source chain):
npx hardhat deploy-token \ --name "TestOPN" \ --symbol "TSTOPN" \ --supply "2200000" \ --network sepolia
-
Deploy OFTAdapter (source chain):
npx hardhat deploy-oft-adapter \ --token "TOKEN_ADDRESS" \ --network sepolia
-
Deploy OFT (destination chain):
npx hardhat deploy-oft \ --name "TestOFT" \ --symbol "TOFT" \ --network etherlink-testnet
-
Set up peers:
# On source chain npx hardhat set-oftadapter-peer --network sepolia # On destination chain npx hardhat set-oft-peer --network etherlink-testnet
-
Configure options and settings:
# On source chain npx hardhat set-enforced-options --is-for-oft-adapter true --network sepolia npx hardhat set-config --is-for-oft-adapter true --network sepolia # On destination chain npx hardhat set-enforced-options --network etherlink-testnet npx hardhat set-config --network etherlink-testnet
-
From source to destination chain:
npx hardhat send-oft \ --amount "100" \ --receiver "RECEIVER_ADDRESS" \ --network sepolia
-
From destination back to source chain:
npx hardhat send-oft-back \ --amount "100" \ --receiver "RECEIVER_ADDRESS" \ --network etherlink-testnet
--gas-drop
: Amount of native gas to drop on destination chain (in wei)--max-gas
: Maximum gas for executor LayerZero receive option
bun run compile
: Compile contractsbun run test
: Run testsbun run lint
: Run all lintersbun run lint:fix
: Fix linting issuesbun run format
: Format codebun run typecheck
: Check TypeScript typesbun run coverage
: Generate test coverage reportbun run clean
: Clean build artifacts
The repository uses:
- ESLint for TypeScript linting
- Prettier for code formatting
- Solhint for Solidity linting
- Husky for git hooks
- lint-staged for pre-commit checks
Supported networks:
- Ethereum Mainnet
- Sepolia Testnet
- Etherlink Mainnet
- Etherlink Testnet
Configure additional networks in hardhat.config.ts
.
Common LayerZero error codes:
0xf6ff4fb7
: Peer not set0x91ac5e4f
: Invalid endpoint call0x0fbdec0a
: Invalid endpoint caller0x9f704120
: Insufficient native gas0x5373352a
: LayerZero token unavailable0x71c4efed
: Slippage exceeded0x1e9714b0
: Invalid local decimals0x9a6d49cd
: Invalid options0xb5863604
: Invalid delegate0xc26bebcc
: Only peer can call this function
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.