Skip to content

Commit 3b6eff4

Browse files
authored
Develop (#5)
1 parent 4ed744e commit 3b6eff4

File tree

31 files changed

+1376
-103
lines changed

31 files changed

+1376
-103
lines changed

.env.template

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Ethereum Sepolia Configuration
2+
SEPOLIA_RPC_URL="https://gateway.tenderly.co/public/sepolia"
3+
LAYER_ZERO_SEPOLIA_ENDPOINT_ADDRESS=0x6EDCE65403992e310A62460808c4b910D972f10f
4+
LAYER_ZERO_SEPOLIA_CHAIN_ID=40161 # LayerZero chain ID for Ethereum Sepolia
5+
RLC_SEPOLIA_ADAPTER_ADDRESS=0x<deployed-rlc-adapter-address-on-sepolia>
6+
RLC_SEPOLIA_ADDRESS=0x<rlc-token-address-on-sepolia>
7+
8+
# Arbitrum Sepolia Configuration
9+
ARBITRUM_SEPOLIA_RPC_URL="https://arbitrum-sepolia.gateway.tenderly.co"
10+
LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS=0x6EDCE65403992e310A62460808c4b910D972f10f
11+
LAYER_ZERO_ARBITRUM_SEPOLIA_CHAIN_ID=40231 # LayerZero chain ID for Arbitrum Sepolia
12+
RLC_ARBITRUM_SEPOLIA_OFT_ADDRESS=0x<deployed-rlcoft-address-on-arbitrum-sepolia>
13+
14+
# Token Configuration for OFT
15+
RLC_OFT_TOKEN_NAME="RLC OFT"
16+
RLC_TOKEN_SYMBOL="RLC"
17+
18+
# Transaction Settings
19+
OWNER_ADDRESS=0x<owner-wallet-address>
20+
21+
# API Keys
22+
ETHERSCAN_API_KEY=<your-etherscan-api-key>
23+
ARBISCAN_API_KEY=<your-etherscan-api-key>
24+
25+
# Account info for script execution - can be private key or mnemonic, depending on configuration
26+
ACCOUNT=<account-identifier-for-forge>

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
run: |
3737
forge build --sizes
3838
id: build
39-
40-
- name: Run Forge tests
41-
run: |
42-
forge test -vvv
43-
id: test
39+
#TDO: Uncomment when tests are available
40+
# - name: Run Forge tests
41+
# run: |
42+
# forge test -vvv
43+
# id: test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ out/
66
!/broadcast
77
/broadcast/*/31337/
88
/broadcast/**/dry-run/
9+
# Foundry broadcast files
10+
broadcast/*/*/run-*.json
11+
!broadcast/*/*/run-latest.json
12+
913

1014
# Docs
1115
docs/
1216

1317
# Dotenv file
1418
.env
19+
.last_deploy.json

.gitmodules

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/devtools"]
5+
path = lib/devtools
6+
url = https://github.com/LayerZero-Labs/devtools
7+
[submodule "lib/layerzero-v2"]
8+
path = lib/layerzero-v2
9+
url = https://github.com/LayerZero-Labs/layerzero-v2
10+
[submodule "lib/rlc-faucet-contract"]
11+
path = lib/rlc-faucet-contract
12+
url = https://github.com/iExecBlockchainComputing/rlc-faucet-contract
13+
[submodule "lib/openzeppelin-contracts-upgradeable"]
14+
path = lib/openzeppelin-contracts-upgradeable
15+
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
16+
[submodule "lib/openzeppelin-foundry-upgrades"]
17+
path = lib/openzeppelin-foundry-upgrades
18+
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
19+
[submodule "lib/openzeppelin-contracts"]
20+
path = lib/openzeppelin-contracts
21+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Changelog
2+
3+
## vNEXT
4+
5+
### Added
6+
- Initial implementation of RLC OFT (Optimistic Fungible Token) bridge system
7+
- RLCOFT contract deployed on Arbitrum Sepolia with 9 decimal places
8+
- RLCAdapter contract deployed on Ethereum Sepolia to bridge existing RLC token
9+
- Cross-chain message passing functionality using LayerZero protocol
10+
- Configuration scripts for trustless omnichain communication setup
11+
- Token transfer capabilities between Ethereum Sepolia and Arbitrum Sepolia
12+
- `approveAndCall` function for one-step approval and contract interaction
13+
- Burn capability for RLCOFT tokens
14+
- Comprehensive deployment scripts using Foundry
15+
- Configuration utilities to set trusted remote addresses
16+
- Verification targets for block explorer verification
17+
- End-to-end cross-chain transfer test scripts

Makefile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Makefile for RLC OFT Project
2+
-include .env
3+
4+
# Test and utility targets
5+
test:
6+
@echo "Running tests..."
7+
forge test -vvv
8+
9+
clean:
10+
@echo "Cleaning artifacts..."
11+
forge clean
12+
13+
# Deployment targets
14+
deploy-adapter:
15+
@echo "Deploying RLCAdapter on SEPOLIA..."
16+
forge script script/RLCAdapter.s.sol:Deploy \
17+
--rpc-url $(SEPOLIA_RPC_URL) \
18+
--account $(ACCOUNT) \
19+
--broadcast \
20+
-vvv
21+
22+
deploy-oft:
23+
@echo "Deploying RLCOFT on Arbitrum SEPOLIA..."
24+
forge script script/RLCOFT.s.sol:Deploy \
25+
--rpc-url $(ARBITRUM_SEPOLIA_RPC_URL) \
26+
--account $(ACCOUNT) \
27+
--broadcast \
28+
-vvv \
29+
30+
configure-adapter:
31+
@echo "Configuring RLCAdapter on SEPOLIA..."
32+
forge script script/RLCAdapter.s.sol:Configure \
33+
--rpc-url $(SEPOLIA_RPC_URL) \
34+
--account $(ACCOUNT) \
35+
--broadcast \
36+
-vvv
37+
configure-oft:
38+
@echo "Configuring RLCOFT on Arbitrum SEPOLIA..."
39+
forge script script/RLCOFT.s.sol:Configure \
40+
--rpc-url $(ARBITRUM_SEPOLIA_RPC_URL) \
41+
--account $(ACCOUNT) \
42+
--broadcast \
43+
-vvv
44+
45+
send-tokens-to-arbitrum-sepolia:
46+
@echo "Sending tokens cross-chain... from SEPOLIA to Arbitrum SEPOLIA"
47+
forge script script/SendEthereumToArbitrum.s.sol:SendTokensToArbitrumSepolia \
48+
--rpc-url $(SEPOLIA_RPC_URL) \
49+
--account $(ACCOUNT) \
50+
--broadcast \
51+
-vvv
52+
53+
send-tokens-to-sepolia:
54+
@echo "Sending tokens cross-chain... from Arbitrum SEPOLIA to SEPOLIA"
55+
forge script script/SendArbitrumToEthereum.s.sol:SendTokensToSepolia \
56+
--rpc-url $(ARBITRUM_SEPOLIA_RPC_URL) \
57+
--account $(ACCOUNT) \
58+
--broadcast \
59+
-vvv
60+
61+
# Verification targets
62+
verify-adapter:
63+
@echo "Verifying RLCAdapter on Sepolia Etherscan..."
64+
forge verify-contract \
65+
--chain-id 11155111 \
66+
--watch \
67+
--constructor-args $(shell cast abi-encode "constructor(address,address,address)" $(RLC_SEPOLIA_ADDRESS) $(LAYER_ZERO_SEPOLIA_ENDPOINT_ADDRESS) $(OWNER_ADDRESS)) \
68+
--etherscan-api-key $(ETHERSCAN_API_KEY) \
69+
$(RLC_SEPOLIA_ADAPTER_ADDRESS) \
70+
src/RLCAdapter.sol:RLCAdapter
71+
72+
verify-oft:
73+
@echo "Verifying RLCOFT on Arbitrum Sepolia Etherscan..."
74+
forge verify-contract \
75+
--chain-id 421614 \
76+
--watch \
77+
--constructor-args $(shell cast abi-encode "constructor(string,string,address,address)" $(RLC_OFT_TOKEN_NAME) $(RLC_TOKEN_SYMBOL) $(LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS) $(OWNER_ADDRESS)) \
78+
--etherscan-api-key $(ARBISCAN_API_KEY) \
79+
$(RLC_ARBITRUM_SEPOLIA_OFT_ADDRESS) \
80+
src/RLCOFT.sol:RLCOFT
81+
82+
# Combined verification target
83+
verify-all: verify-adapter verify-oft
84+

README.md

Lines changed: 126 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,151 @@
1-
## Foundry
1+
# RLC Layer Zero Bridge
22

3-
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
3+
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.
44

5-
Foundry consists of:
5+
## Architecture
66

7-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
7+
The system consists of two main components:
118

12-
## Documentation
9+
1. **RLCAdapter (on Ethereum Sepolia)**: Wraps the existing RLC ERC-20 token to make it compatible with LayerZero's cross-chain messaging.
10+
2. **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.
1311

14-
https://book.getfoundry.sh/
12+
[![Architecture Diagram](https://mermaid.ink/img/pako:eNqNVNtO4zAQ_RXLvAY2F3JpQEhpLrsPRUhQXqBoZRKXRjh2ZCdouf372nHSEhrYddV2MjnHZ-ZM4leYswLDED5wVG_AMllRIJdo73ViBdNmgzluK3CFa0ZKtIIaotblIr6VX7Bkj5ju0qflWXoZ2-bpj_LsbpeOClQ3mCtGH44oF9myT3_iLW5-p8tftwv0jPkN5gyktKhZSZseg2mhg73aI35fNny6dimnKpF_E-XL7H4R0eX8v4u4Fph3VasAMAoGG-_A4eHZmwWiuubsCQvQKHHxBkaWDPQObIMYESKAkBqfcP1FB3PAguWPuw1lc_ugY2kFLQSosBDoAb_15mqgjjucC2LOhDjMN6ikI7R0YYuWcYf2QIJJ-YT5h42lhRqnHFYgH5xLu3b1dT0qTweLhmnd7Rk56EQjJ_YU5mDecrpT2APEE91P9ZN82f2UV-lE919OKQPXlPx7Tj_BkiMq1mrTkWHbAvRvTpAQCV4DPLym65KQ8CD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drp5pDkMpjg3Y1gVqcFIieUBVMFwjImS2RvSGsWoAyUsYvsI_MAysI8_yfNuZeY7tuUFgwGcYWjP3yLdN1_Jl5PiBab8b8KXbwDyaufbMOnYs27OsIPA8A3LWPmy2WrgoG8bP9ZnfHf2GPPpVN1qcy_cD85i1tJFKlj3UnHY8jXr_C5RA8AI)
1513

16-
## Usage
14+
## Prerequisites
1715

18-
### Build
16+
- [Foundry](https://book.getfoundry.sh/getting-started/installation.html) for contract compilation and deployment
17+
- Ethereum wallet with Sepolia ETH and Arbitrum Sepolia ETH for gas
18+
- RLC tokens on Sepolia testnet for bridge testing
1919

20-
```shell
21-
$ forge build
22-
```
20+
## Installation
2321

24-
### Test
22+
1. Clone the repository
2523

26-
```shell
27-
$ forge test
28-
```
24+
```bash
25+
git clone https://github.com/iExecBlockchainComputing/rlc-multichain.git
26+
cd rlc-multichain
27+
```
2928

30-
### Format
29+
2. Install dependencies
3130

32-
```shell
33-
$ forge fmt
34-
```
31+
```bash
32+
forge install
33+
```
3534

36-
### Gas Snapshots
35+
3. Create a `.env` file
3736

38-
```shell
39-
$ forge snapshot
40-
```
37+
```sh
38+
cp .env.template .env # and edit .env content
39+
```
4140

42-
### Anvil
41+
**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:
4342

44-
```shell
45-
$ anvil
43+
```bash
44+
cast wallet import --private-key <RAW_PRIVATE_KEY> <ACCOUNT_NAME>
4645
```
4746

48-
### Deploy
47+
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.
4948

50-
```shell
51-
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52-
```
49+
## Contract Overview
50+
51+
Instead of duplicating code that may become outdated, here are links to the key contracts in the repository:
52+
53+
- [RLCAdapter.sol](https://github.com/iExecBlockchainComputing/rlc-multichain/blob/main/src/RLCAdapter.sol) - Ethereum-side adapter that wraps the existing RLC token
54+
- [RLCOFT.sol](https://github.com/iExecBlockchainComputing/rlc-multichain/blob/main/src/RLCOFT.sol) - Arbitrum-side token that implements the OFT standard
55+
56+
## Deployment
57+
58+
The deployment process involves four steps:
59+
60+
1. Deploy the RLCAdapter on Ethereum Sepolia:
61+
62+
```bash
63+
make deploy-adapter
64+
```
65+
66+
2. Deploy the RLCOFT on Arbitrum Sepolia:
67+
68+
```bash
69+
make deploy-oft
70+
```
71+
72+
3. Configure the RLCAdapter to trust the RLCOFT contract:
73+
74+
```bash
75+
make configure-adapter
76+
```
77+
78+
4. Configure the RLCOFT to trust the RLCAdapter contract:
79+
80+
```bash
81+
make configure-oft
82+
```
83+
84+
After deployment, update your `.env` file with the deployed contract addresses.
5385

54-
### Cast
86+
## Usage
87+
88+
### Bridge RLC
89+
90+
A. To send RLC tokens from Ethereum Sepolia to Arbitrum Sepolia:
5591

56-
```shell
57-
$ cast <subcommand>
92+
```bash
93+
make send-tokens-to-arbitrum-sepolia
5894
```
5995

60-
### Help
96+
This will:
97+
98+
1. Approve the RLCAdapter to spend your RLC tokens
99+
2. Initiate the cross-chain transfer through LayerZero
100+
3. Lock tokens in the adapter and mint equivalent tokens on Arbitrum
101+
102+
B. To send RLC tokens from Arbitrum Sepolia back to Ethereum Sepolia:
61103

62-
```shell
63-
$ forge --help
64-
$ anvil --help
65-
$ cast --help
104+
```bash
105+
make send-tokens-to-sepolia
66106
```
107+
108+
This will:
109+
110+
1. Burn RLCOFT tokens on Arbitrum
111+
2. Send a cross-chain message to the adapter
112+
3. Release the original RLC tokens on Ethereum
113+
114+
## How It Works
115+
116+
1. **Ethereum → Arbitrum:**
117+
- User approves RLCAdapter to spend RLC tokens
118+
- RLCAdapter locks the RLC tokens
119+
- LayerZero delivers a message to RLCOFT
120+
- RLCOFT mints equivalent tokens to the recipient on Arbitrum
121+
122+
2. **Arbitrum → Ethereum:**
123+
- User initiates transfer from RLCOFT
124+
- RLCOFT burns the tokens
125+
- LayerZero delivers a message to RLCAdapter
126+
- RLCAdapter unlocks the original RLC tokens to the recipient on Ethereum
127+
128+
## Security Considerations
129+
130+
- The bridge security relies on LayerZero's security model
131+
- Administrative functions are protected by the Ownable pattern
132+
- Use caution when setting trusted remotes to prevent unauthorized cross-chain interactions
133+
- Always test thoroughly on testnets before deploying to mainnet
134+
135+
## Gas Costs and Fees
136+
137+
LayerZero transactions require fees to cover:
138+
139+
1. Gas on the source chain
140+
2. Gas on the destination chain (prepaid)
141+
3. LayerZero relayer fees
142+
143+
The scripts automatically calculate these fees and include them in the transaction.
144+
145+
## Troubleshooting
146+
147+
## References
148+
149+
- [LayerZero Documentation](https://layerzero.gitbook.io/docs/)
150+
- [OFT Contracts](https://github.com/LayerZero-Labs/solidity-examples/tree/main/contracts/token/oft)
151+
- [iExec Platform Documentation](https://docs.iex.ec/)

0 commit comments

Comments
 (0)