Skip to content

Commit 3e28e9f

Browse files
committed
chore(multichain):enable multiple chain bridge
1 parent ef64afb commit 3e28e9f

7 files changed

+224
-89
lines changed

.env.example

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
ETHEREUM_RPC_URL="https://1rpc.io/eth"
22
BASE_RPC_URL="https://mainnet.base.org"
3-
ARBITRUM_RPC_URL="YOUR_ARBITRUM_RPC_URL"
4-
5-
# Token Address on Ethereum
6-
erc20TokenAddress="0x33333333fede34409fb7f67c6585047e1f653333"
7-
# LayerZero EndPoint on Ethereum
8-
lzEndpointOnSrcChain=0x1a44076050125825900e736c501f859c50fE728c
9-
lzEndpointIdOnSrcChain=30101
10-
# LayerZero EndPoint on Base
11-
lzEndpointOnDestChain=0x1a44076050125825900e736c501f859c50fE728c
12-
lzEndpointIdOnDestChain=30184
13-
# Ethereum OFT Adapter Address
14-
oftAdapterContractAddress=0x5e1F75388dc768f6129b9ee859BFB1361631a77e
15-
# Base OFT Token Address
16-
oftContractAddress=0x333333C465a19C85f85c6CfbED7B16b0B26E3333
3+
ARBITRUM_RPC_URL="https://arb1.arbitrum.io/rpc"
4+
BSC_MAINNET_RPC_URL="https://bsc-dataseed1.binance.org/"
175

186
# No need to change
197
executorLzReceiveOptionMaxGas=200000

README.md

+64-12
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,75 @@ Follow these steps to set up the project on your local machine:
7272

7373
Once you've configured the environment variables, you can run the following commands to send OFT tokens across chains:
7474

75-
### Send Tokens to Base Network
75+
### Sending Tokens Between Networks
7676

77-
To send OFT tokens from the mainnet to the Base network, run the following command:
77+
#### Ethereum to Other Networks
7878

79-
```bash
80-
yarn run ora-eth-to-base
81-
```
79+
- **To Arbitrum:**
80+
```bash
81+
yarn run ora-eth-to-arbitrum
82+
```
8283

83-
This command will send the specified amount of tokens from the mainnet to the receiver address on the Base network.
84+
- **To Base:**
85+
```bash
86+
yarn run ora-eth-to-base
87+
```
8488

85-
### Send Tokens Back to Mainnet
89+
- **To Binance:**
90+
```bash
91+
yarn run ora-eth-to-binance
92+
```
8693

87-
To send OFT tokens back from the Base network to the origin chain (e.g., mainnet), run the following command:
94+
#### Base to Other Networks
8895

89-
```bash
90-
yarn run ora-base-to-eth
91-
```
96+
- **To Ethereum:**
97+
```bash
98+
yarn run ora-base-to-eth
99+
```
100+
101+
- **To Binance:**
102+
```bash
103+
yarn run ora-base-to-binance
104+
```
105+
106+
- **To Arbitrum:**
107+
```bash
108+
yarn run ora-base-to-arbitrum
109+
```
110+
111+
#### Arbitrum to Other Networks
112+
113+
- **To Base:**
114+
```bash
115+
yarn run ora-arbitrum-to-base
116+
```
117+
118+
- **To Binance:**
119+
```bash
120+
yarn run ora-arbitrum-to-binance
121+
```
122+
123+
- **To Ethereum:**
124+
```bash
125+
yarn run ora-arbitrum-to-eth
126+
```
127+
128+
#### Binance to Other Networks
129+
130+
- **To Base:**
131+
```bash
132+
yarn run ora-binance-to-base
133+
```
134+
135+
- **To Arbitrum:**
136+
```bash
137+
yarn run ora-binance-to-arbitrum
138+
```
139+
140+
- **To Ethereum:**
141+
```bash
142+
yarn run ora-binance-to-eth
143+
```
92144

93145
This command will send the tokens back from the Base network to the mainnet.
94146

@@ -122,4 +174,4 @@ This project is licensed under the [MIT License](LICENSE), which allows you to f
122174

123175
---
124176

125-
If you encounter any issues or have questions, please feel free to open an issue or reach out. We hope this tool helps you in your cross-chain token transfer needs!
177+
If you encounter any issues or have questions, please feel free to open an issue or reach out. We hope this tool helps you in your cross-chain token transfer needs!

hardhat.config.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import "dotenv/config";
22
import "@nomicfoundation/hardhat-toolbox";
33
import "@nomicfoundation/hardhat-verify";
44

5-
const ACCOUNTS = process.env.DEPLOYER_ACCOUNT_PRIV_KEY
6-
? [`${process.env.SENDER_BACK_ACCOUNT_PRIV_KEY}`]
5+
const ACCOUNTS = process.env.SENDER_ACCOUNT_PRIV_KEY
6+
? [`${process.env.SENDER_ACCOUNT_PRIV_KEY}`]
77
: [];
88

99
const ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL;
1010
const BASE_RPC_URL = process.env.BASE_RPC_URL;
1111
const ARBITRUM_RPC_URL = process.env.ARBITRUM_RPC_URL;
12+
const BSC_MAINNET_RPC_URL = process.env.BSC_MAINNET_RPC_URL;
1213

1314
module.exports = {
1415
defaultNetwork: "hardhat",
@@ -27,11 +28,6 @@ module.exports = {
2728
url: "https://polygon-mainnet.public.blastapi.io", // "https://polygon-pokt.nodies.app",
2829
accounts: ACCOUNTS,
2930
},
30-
sepolia: {
31-
chainId: 11155111,
32-
url: "https://eth-sepolia.public.blastapi.io",
33-
accounts: ACCOUNTS,
34-
},
3531
ethereum: {
3632
chainId: 1,
3733
url: ETHEREUM_RPC_URL,
@@ -52,6 +48,11 @@ module.exports = {
5248
url: ARBITRUM_RPC_URL,
5349
accounts: ACCOUNTS,
5450
},
51+
binance: {
52+
chainId: 56,
53+
url: BSC_MAINNET_RPC_URL,
54+
accounts: ACCOUNTS,
55+
}
5556
},
5657
etherscan: {
5758
customChains: [

package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
"version": "1.0.0",
44
"description": "oft-cc-script",
55
"scripts": {
6-
"ora-eth-to-base": "npx hardhat run scripts/send_via_oft_adapter.ts --network ethereum",
7-
"ora-base-to-eth": "npx hardhat run scripts/send_via_oft.ts --network base"
6+
"ora-eth-to-arbitrum": "export PATHWAY='ETHEREUM->ARBITRUM' && npx hardhat run scripts/send_via_oft_adapter.ts --network ethereum",
7+
"ora-eth-to-base": "export PATHWAY='ETHEREUM->BASE' && npx hardhat run scripts/send_via_oft_adapter.ts --network ethereum",
8+
"ora-eth-to-binance": "export PATHWAY='ETHEREUM->BINANCE' && npx hardhat run scripts/send_via_oft_adapter.ts --network ethereum",
9+
"ora-base-to-eth": "export PATHWAY='BASE->ETHEREUM' && npx hardhat run scripts/send_via_oft.ts --network base",
10+
"ora-base-to-binance": "export PATHWAY='BASE->BINANCE' && npx hardhat run scripts/send_via_oft.ts --network base",
11+
"ora-base-to-arbitrum": "export PATHWAY='BASE->ARBITRUM' && npx hardhat run scripts/send_via_oft.ts --network base",
12+
"ora-arbitrum-to-base": "export PATHWAY='ARBITRUM->BASE' && npx hardhat run scripts/send_via_oft.ts --network arbitrum",
13+
"ora-arbitrum-to-binance": "export PATHWAY='ARBITRUM->BINANCE' && npx hardhat run scripts/send_via_oft.ts --network arbitrum",
14+
"ora-arbitrum-to-eth": "export PATHWAY='ARBITRUM->ETHEREUM' && npx hardhat run scripts/send_via_oft.ts --network arbitrum",
15+
"ora-binance-to-base": "export PATHWAY='BINANCE->BASE' && npx hardhat run scripts/send_via_oft.ts --network binance",
16+
"ora-binance-to-arbitrum": "export PATHWAY='BINANCE->ARBITRUM' && npx hardhat run scripts/send_via_oft.ts --network binance",
17+
"ora-binance-to-eth": "export PATHWAY='BINANCE->ETHEREUM' && npx hardhat run scripts/send_via_oft.ts --network binance"
818
},
919
"devDependencies": {
1020
"@ethersproject/bytes": "^5.7.0",

scripts/layer0_bridge_data.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const CHAIN_CONFIG: any = {
2+
ARBITRUM: {
3+
oftContractAddress: "0x333333c465a19c85f85c6cfbed7b16b0b26e3333",
4+
lzEndpointIdOnCurrentChain: 30110,
5+
},
6+
BASE: {
7+
oftContractAddress: "0x333333c465a19c85f85c6cfbed7b16b0b26e3333",
8+
lzEndpointIdOnCurrentChain: 30184,
9+
},
10+
BINANCE: {
11+
oftContractAddress: "0x333333c465a19c85f85c6cfbed7b16b0b26e3333",
12+
lzEndpointIdOnCurrentChain: 30102,
13+
},
14+
ETHEREUM: {
15+
tokenContractAddress: "0x33333333fede34409fb7f67c6585047e1f653333",
16+
oftContractAddress: "0x5e1f75388dc768f6129b9ee859bfb1361631a77e",
17+
lzEndpointIdOnCurrentChain: 30101,
18+
}
19+
};
20+
21+
const PATHWAY_CONFIG = (srcChain: string, destChain: string) => {
22+
if (!CHAIN_CONFIG[srcChain]) {
23+
throw new Error(`Chain config for ${srcChain} missing`);
24+
} else if (!CHAIN_CONFIG[destChain]) {
25+
throw new Error(`Chain config for ${destChain} missing`);
26+
}
27+
28+
return {
29+
...CHAIN_CONFIG[srcChain],
30+
lzEndpointIdOnRemoteChain: CHAIN_CONFIG[destChain].lzEndpointIdOnCurrentChain,
31+
oftContractAddressOnRemoteChain: CHAIN_CONFIG[srcChain].oftContractAddress,
32+
};
33+
};
34+
35+
export default PATHWAY_CONFIG;

0 commit comments

Comments
 (0)