This project implements a cross-chain token bridge for the RLC token between Ethereum and Arbitrum using LayerZero's OFT (Omnichain Fungible Token) protocol. It enables seamless token transfers between Ethereum Sepolia and Arbitrum Sepolia testnets.
The system consists of two main components:
- RLCAdapter (on Ethereum Sepolia): Wraps the existing RLC ERC-20 token to make it compatible with LayerZero's cross-chain messaging.
- RLCOFT (on Arbitrum Sepolia): A new token that's minted when RLC tokens are locked in the adapter on Ethereum, and burned when tokens are sent back.
- Foundry for contract compilation and deployment
- Ethereum wallet with Sepolia ETH and Arbitrum Sepolia ETH for gas
- RLC tokens on Sepolia testnet for bridge testing
-
Clone the repository
git clone https://github.com/iExecBlockchainComputing/rlc-multichain.git cd rlc-multichain -
Install dependencies
forge install
-
Create a
.envfilecp .env.template .env # and edit .env content
Note: To run scripts, you must save a wallet in the Foundry keystore. Use the following command to import a wallet with a raw private key:
cast wallet import --private-key <RAW_PRIVATE_KEY> <ACCOUNT_NAME>Alternatively, you can use a mnemonic by specifying the --mnemonic-path option. Remember the <ACCOUNT_NAME> you choose, and set it in your .env file under the ACCOUNT field.
Instead of duplicating code that may become outdated, here are links to the key contracts in the repository:
- RLCAdapter.sol - Ethereum-side adapter that wraps the existing RLC token
- RLCOFT.sol - Arbitrum-side token that implements the OFT standard
The deployment process involves four steps:
-
Deploy the RLCAdapter on Ethereum Sepolia:
make deploy-adapter
-
Deploy the RLCOFT on Arbitrum Sepolia:
make deploy-oft
-
Configure the RLCAdapter to trust the RLCOFT contract:
make configure-adapter
-
Configure the RLCOFT to trust the RLCAdapter contract:
make configure-oft
After deployment, update your .env file with the deployed contract addresses.
A. To send RLC tokens from Ethereum Sepolia to Arbitrum Sepolia:
make send-tokens-to-arbitrum-sepoliaThis will:
- Approve the RLCAdapter to spend your RLC tokens
- Initiate the cross-chain transfer through LayerZero
- Lock tokens in the adapter and mint equivalent tokens on Arbitrum
B. To send RLC tokens from Arbitrum Sepolia back to Ethereum Sepolia:
make send-tokens-to-sepoliaThis will:
- Burn RLCOFT tokens on Arbitrum
- Send a cross-chain message to the adapter
- Release the original RLC tokens on Ethereum
-
Ethereum → Arbitrum:
- User approves RLCAdapter to spend RLC tokens
- RLCAdapter locks the RLC tokens
- LayerZero delivers a message to RLCOFT
- RLCOFT mints equivalent tokens to the recipient on Arbitrum
-
Arbitrum → Ethereum:
- User initiates transfer from RLCOFT
- RLCOFT burns the tokens
- LayerZero delivers a message to RLCAdapter
- RLCAdapter unlocks the original RLC tokens to the recipient on Ethereum
- The bridge security relies on LayerZero's security model
- Administrative functions are protected by the Ownable pattern
- Use caution when setting trusted remotes to prevent unauthorized cross-chain interactions
- Always test thoroughly on testnets before deploying to mainnet
LayerZero transactions require fees to cover:
- Gas on the source chain
- Gas on the destination chain (prepaid)
- LayerZero relayer fees
The scripts automatically calculate these fees and include them in the transaction.