Skip to content

Commit fc2d2df

Browse files
authored
Merge pull request #126 from OffchainLabs/update-tutorials-2
Update tutorials to ArbSDK v4 (2)
2 parents 45112c7 + b0eadb0 commit fc2d2df

17 files changed

Lines changed: 381 additions & 380 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ yarn install
3737

3838
#### :white_check_mark: Advanced features
3939

40-
- ®️ [Arb Address Table](./packages/address-table/)
41-
- 🌉 [Bridging Custom Token](./packages/custom-token-bridging/)
40+
- ®️ [ArbAddress table](./packages/address-table/)
41+
- 🌉 [Bridging a custom token through the generic-custom gateway](./packages/custom-token-bridging/)
42+
- 🌉 [Bridging a custom token through a custom gateway](./packages/custom-gateway-bridging/)
4243
- ✈️ [Send a signed transaction from the parent chain](./packages/delayedInbox-l2msg/)
4344
- 🎁 [Redeem Retryable Ticket](./packages/redeem-failed-retryable/)
4445
- 🌀 [Deposit Ether or Tokens from L1 to L3](./packages/l1-l3-teleport/)
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
# This is a sample .env file for use in local development.
2-
32
# Duplicate this file as .env here
43

5-
# Your Private key
6-
7-
DEVNET_PRIVKEY="0x your key here"
8-
9-
# Hosted Aggregator Node (JSON-RPC Endpoint). This is Arbitrum Sepolia Testnet, can use any Arbitrum chain
10-
11-
L2RPC="https://sepolia-rollup.arbitrum.io/rpc"
4+
# Your private key
5+
PRIVATE_KEY="0x your key here"
126

13-
# Ethereum RPC; i.e., for Sepolia https://sepolia.infura.io/v3/<your infura key>
7+
# The main chain's RPC
8+
# (this can be an Arbitrum network, or your Orbit chain)
9+
CHAIN_RPC="https://sepolia-rollup.arbitrum.io/rpc"
1410

15-
L1RPC=""
11+
# The parent chain's RPC
12+
# (this can be Ethereum, or the chain your Orbit chain settles to)
13+
PARENT_CHAIN_RPC="https://sepolia.infura.io/v3/<your infura key>"

packages/custom-gateway-bridging/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
# Custom gateway bridging tutorial
22

3-
When neither the StandardERC20gateway nor the generic-custom-gateway are enough to fulfill the bridging requirements of a token, there is the possibility of creating and registering a custom gateway. `custom-gateway-bridging` demonstrates how to create and register a custom gateway in Arbitrum's Token Bridge protocol.
3+
When neither the standard ERC20 gateway, nor the generic-custom gateway are enough to fulfill the bridging requirements of a token, there is the possibility of creating and registering a custom gateway. `custom-gateway-bridging` demonstrates how to create and register a custom gateway in the Arbitrum's Token Bridge.
44

5-
For more info on bridging assets on Arbitrum, see our [token bridging docs](https://developer.arbitrum.io/asset-bridging).
5+
For more info on bridging assets on Arbitrum, see our [token bridging docs](https://docs.arbitrum.io/build-decentralized-apps/token-bridging/token-bridge-erc20).
66

77
## Token bridging using a custom gateway
88

99
Bridging custom tokens through a custom gateway follow a similar process than that of Arbitrum's generic-custom gateway. The difference, however, is that during the gateway registration process, a custom gateway is registered instead of the generic-custom gateway.
1010

11-
Here, we deploy a [demo custom token](./contracts/L1Token.sol) on L1 and a [demo custom token](./contracts/L2Token.sol) on L2. We also deploy a demo custom gateway on both [L1](./contracts/L1CustomGateway.sol) and [L2](./contracts/L2CustomGateway.sol). We then use the Arbitrum router contract to register our L1 and L2 gateways.
11+
Here, we deploy a [demo custom token](./contracts/ParentChainToken.sol) to the parent chain and a [demo custom token](./contracts/ChildChainToken.sol) to the child chain. We also deploy a demo custom gateway on both [the parent chain](./contracts/ParentChainCustomGateway.sol) and [the child chain](./contracts/ChildChainCustomGateway.sol). We then use the Arbitrum router contract to register both gateways.
1212

1313
We use the [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk) library to initiate and verify the bridging.
1414

1515
See [./exec.js](./scripts/exec.js) for inline explanation.
1616

17-
### Config Environment Variables
17+
### Set environment variables
1818

1919
Set the values shown in `.env-sample` as environmental variables. To copy it into a `.env` file:
2020

2121
```bash
2222
cp .env-sample .env
2323
```
2424

25-
(you'll still need to edit some variables, i.e., `DEVNET_PRIVKEY`)
25+
You'll still need to edit some variables, i.e., `PRIVATE_KEY`, `CHAIN_RPC`, `PARENT_CHAIN_RPC`.
26+
27+
Note that you can also set the environment variables in an `.env` file in the root of the monorepo, which will be available in all tutorials.
2628

2729
### Run:
2830

packages/custom-gateway-bridging/contracts/L2CustomGateway.sol renamed to packages/custom-gateway-bridging/contracts/ChildChainCustomGateway.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "@openzeppelin/contracts/access/Ownable.sol";
1111
* @dev Inheritance of Ownable is optional. In this case we use it to call the function setTokenBridgeInformation
1212
* and simplify the test
1313
*/
14-
contract L2CustomGateway is IL2CustomGateway, L2CrosschainMessenger, Ownable {
14+
contract ChildChainCustomGateway is IL2CustomGateway, L2CrosschainMessenger, Ownable {
1515
// Exit number (used for tradeable exits)
1616
uint256 public exitNum;
1717

packages/custom-gateway-bridging/contracts/L2Token.sol renamed to packages/custom-gateway-bridging/contracts/ChildChainToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
77
/**
88
* @title Example implementation of a custom ERC20 token to be deployed on L2
99
*/
10-
contract L2Token is ERC20, IArbToken {
10+
contract ChildChainToken is ERC20, IArbToken {
1111
address public l2GatewayAddress;
1212
address public override l1Address;
1313

packages/custom-gateway-bridging/contracts/L1CustomGateway.sol renamed to packages/custom-gateway-bridging/contracts/ParentChainCustomGateway.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "@openzeppelin/contracts/access/Ownable.sol";
1111
* @dev Inheritance of Ownable is optional. In this case we use it to call the function setTokenBridgeInformation
1212
* and simplify the test
1313
*/
14-
contract L1CustomGateway is IL1CustomGateway, L1CrosschainMessenger, Ownable {
14+
contract ParentChainCustomGateway is IL1CustomGateway, L1CrosschainMessenger, Ownable {
1515

1616
// Token bridge state variables
1717
address public l1CustomToken;

packages/custom-gateway-bridging/contracts/L1Token.sol renamed to packages/custom-gateway-bridging/contracts/ParentChainToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface IL1GatewayRouter {
3535
/**
3636
* @title Example implementation of a custom ERC20 token to be deployed on L1
3737
*/
38-
contract L1Token is Ownable, ICustomToken, ERC20 {
38+
contract ParentChainToken is Ownable, ICustomToken, ERC20 {
3939
address public l1GatewayAddress;
4040
address public routerAddress;
4141
bool private shouldRegisterGateway;

packages/custom-gateway-bridging/package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@
55
"build": "hardhat compile",
66
"exec": "hardhat run scripts/exec.js"
77
},
8-
"devDependencies": {
9-
"@nomiclabs/hardhat-ethers": "^2.0.2",
10-
"@openzeppelin/contracts": "^4.8.3",
11-
"chai": "^4.3.4",
12-
"ethers": "^5.1.2",
13-
"hardhat": "^2.6.6"
14-
},
158
"dependencies": {
16-
"@arbitrum/sdk": "^v3.1.9",
17-
"dotenv": "^8.2.0"
9+
"@arbitrum/sdk": "^4.0.1",
10+
"@openzeppelin/contracts": "^4.8.3"
1811
}
1912
}

0 commit comments

Comments
 (0)