Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 42f75d8

Browse files
committed
add native bridge doc
1 parent e4c81ae commit 42f75d8

8 files changed

+10750
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ main
1313
.env*
1414

1515
node_modules/
16+
secrets.json

bridge/native/README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Native Bridge Examples
2+
3+
This repository collects a couple examples of how to call the smart contracts to bridge native ETH and ERC20 tokens to Base.
4+
5+
## Hardhat Scripts
6+
7+
Copy secrets.json.sample to secrets.json
8+
9+
```
10+
cp secrets.json.sample secrets.json
11+
```
12+
13+
Add in your test wallet mnemonic and an alchemy key
14+
15+
If you are new to alchemy, a quickstart is [available here](https://docs.alchemy.com/docs/alchemy-quickstart-guide)
16+
17+
To verify the values are correct, check the balance with.
18+
19+
```
20+
npx hardhat balance
21+
```
22+
23+
You can bridge ETH.
24+
25+
```
26+
npx hardhat bridge --amount 0.1
27+
```
28+
29+
You can bridge any supported ERC20 token.
30+
31+
WETH on goerli: 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6
32+
33+
WETH on base-goerli: 0x4200000000000000000000000000000000000006
34+
35+
If you need WETH, you can wrap easily on [uniswap](https://app.uniswap.org/#/swap?chain=goerli)
36+
37+
Cross-chain token addresses can be found in the [Optimism Token List](https://github.com/ethereum-optimism/ethereum-optimism.github.io)
38+
39+
You bridge a token with
40+
41+
```
42+
npx hardhat bridgeToken --amount 0.01 --l1token 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 --l2token 0x4200000000000000000000000000000000000006
43+
```
44+
45+
## UI
46+
47+
This is a simple example using OP SDK to bridge native ETH.
48+
49+
[Demo](https://op-stack-bridge-example.vercel.app/)
50+
51+
[Code](https://github.com/wilsoncusack/op-stack-bridge-example)
52+
53+
## Add your token to Base
54+
55+
If you already have an ERC20 on Ethereum and want to bridge to Base, a guide is available [here](https://docs.base.org/tokens/list)

bridge/native/abi/erc20.json

+249
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
[
2+
{
3+
"inputs": [
4+
{ "internalType": "address[]", "name": "holders", "type": "address[]" },
5+
{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }
6+
],
7+
"stateMutability": "nonpayable",
8+
"type": "constructor"
9+
},
10+
{
11+
"anonymous": false,
12+
"inputs": [
13+
{
14+
"indexed": true,
15+
"internalType": "address",
16+
"name": "_owner",
17+
"type": "address"
18+
},
19+
{
20+
"indexed": true,
21+
"internalType": "address",
22+
"name": "_spender",
23+
"type": "address"
24+
},
25+
{
26+
"indexed": false,
27+
"internalType": "uint256",
28+
"name": "_value",
29+
"type": "uint256"
30+
}
31+
],
32+
"name": "Approval",
33+
"type": "event"
34+
},
35+
{
36+
"anonymous": false,
37+
"inputs": [
38+
{
39+
"indexed": true,
40+
"internalType": "address",
41+
"name": "previousOwner",
42+
"type": "address"
43+
},
44+
{
45+
"indexed": true,
46+
"internalType": "address",
47+
"name": "newOwner",
48+
"type": "address"
49+
}
50+
],
51+
"name": "OwnershipTransferred",
52+
"type": "event"
53+
},
54+
{
55+
"anonymous": false,
56+
"inputs": [
57+
{
58+
"indexed": true,
59+
"internalType": "address",
60+
"name": "_from",
61+
"type": "address"
62+
},
63+
{
64+
"indexed": true,
65+
"internalType": "address",
66+
"name": "_to",
67+
"type": "address"
68+
},
69+
{
70+
"indexed": false,
71+
"internalType": "uint256",
72+
"name": "_value",
73+
"type": "uint256"
74+
}
75+
],
76+
"name": "Transfer",
77+
"type": "event"
78+
},
79+
{
80+
"anonymous": false,
81+
"inputs": [
82+
{
83+
"indexed": false,
84+
"internalType": "address",
85+
"name": "operator",
86+
"type": "address"
87+
},
88+
{
89+
"indexed": false,
90+
"internalType": "bool",
91+
"name": "enabled",
92+
"type": "bool"
93+
}
94+
],
95+
"name": "WhitelistedOperator",
96+
"type": "event"
97+
},
98+
{
99+
"inputs": [
100+
{ "internalType": "address", "name": "owner", "type": "address" },
101+
{ "internalType": "address", "name": "spender", "type": "address" }
102+
],
103+
"name": "allowance",
104+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
105+
"stateMutability": "view",
106+
"type": "function"
107+
},
108+
{
109+
"inputs": [
110+
{ "internalType": "address", "name": "spender", "type": "address" },
111+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
112+
],
113+
"name": "approve",
114+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
115+
"stateMutability": "nonpayable",
116+
"type": "function"
117+
},
118+
{
119+
"inputs": [
120+
{ "internalType": "address", "name": "account", "type": "address" }
121+
],
122+
"name": "balanceOf",
123+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
124+
"stateMutability": "view",
125+
"type": "function"
126+
},
127+
{
128+
"inputs": [],
129+
"name": "decimals",
130+
"outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }],
131+
"stateMutability": "view",
132+
"type": "function"
133+
},
134+
{
135+
"inputs": [
136+
{ "internalType": "address", "name": "spender", "type": "address" },
137+
{
138+
"internalType": "uint256",
139+
"name": "subtractedValue",
140+
"type": "uint256"
141+
}
142+
],
143+
"name": "decreaseAllowance",
144+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
145+
"stateMutability": "nonpayable",
146+
"type": "function"
147+
},
148+
{
149+
"inputs": [
150+
{ "internalType": "address", "name": "spender", "type": "address" },
151+
{ "internalType": "uint256", "name": "addedValue", "type": "uint256" }
152+
],
153+
"name": "increaseAllowance",
154+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
155+
"stateMutability": "nonpayable",
156+
"type": "function"
157+
},
158+
{
159+
"inputs": [{ "internalType": "address", "name": "who", "type": "address" }],
160+
"name": "isOperator",
161+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
162+
"stateMutability": "view",
163+
"type": "function"
164+
},
165+
{
166+
"inputs": [],
167+
"name": "name",
168+
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
169+
"stateMutability": "view",
170+
"type": "function"
171+
},
172+
{
173+
"inputs": [],
174+
"name": "owner",
175+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
176+
"stateMutability": "view",
177+
"type": "function"
178+
},
179+
{
180+
"inputs": [],
181+
"name": "renounceOwnership",
182+
"outputs": [],
183+
"stateMutability": "nonpayable",
184+
"type": "function"
185+
},
186+
{
187+
"inputs": [
188+
{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }
189+
],
190+
"name": "supportsInterface",
191+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
192+
"stateMutability": "view",
193+
"type": "function"
194+
},
195+
{
196+
"inputs": [],
197+
"name": "symbol",
198+
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
199+
"stateMutability": "view",
200+
"type": "function"
201+
},
202+
{
203+
"inputs": [],
204+
"name": "totalSupply",
205+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
206+
"stateMutability": "view",
207+
"type": "function"
208+
},
209+
{
210+
"inputs": [
211+
{ "internalType": "address", "name": "recipient", "type": "address" },
212+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
213+
],
214+
"name": "transfer",
215+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
216+
"stateMutability": "nonpayable",
217+
"type": "function"
218+
},
219+
{
220+
"inputs": [
221+
{ "internalType": "address", "name": "sender", "type": "address" },
222+
{ "internalType": "address", "name": "recipient", "type": "address" },
223+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
224+
],
225+
"name": "transferFrom",
226+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
227+
"stateMutability": "nonpayable",
228+
"type": "function"
229+
},
230+
{
231+
"inputs": [
232+
{ "internalType": "address", "name": "newOwner", "type": "address" }
233+
],
234+
"name": "transferOwnership",
235+
"outputs": [],
236+
"stateMutability": "nonpayable",
237+
"type": "function"
238+
},
239+
{
240+
"inputs": [
241+
{ "internalType": "address", "name": "operator", "type": "address" },
242+
{ "internalType": "bool", "name": "enabled", "type": "bool" }
243+
],
244+
"name": "whitelistOperator",
245+
"outputs": [],
246+
"stateMutability": "nonpayable",
247+
"type": "function"
248+
}
249+
]

0 commit comments

Comments
 (0)