Skip to content

Commit cf9a88b

Browse files
authored
Add instructions for factory and chain deployments, and small tweaks for custom network deployments (#383)
* Add instructions for factory and chain deployments, and small tweaks for custom network deployments * Format * Add important admonition at the beginning of the doc
1 parent 3ce9b8c commit cf9a88b

File tree

4 files changed

+185
-1
lines changed

4 files changed

+185
-1
lines changed

.env-sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CREATE2_FACTORY=0x4e59b44847b379578588920cA78FbF26c0B4956C
88

99
# to use the 'custom' hardhat network, set the following variables
1010
CUSTOM_RPC_URL="http://127.0.0.1:8545"
11+
CUSTOM_PRIVKEY="0x"
1112
CUSTOM_ETHERSCAN_API_KEY=
1213
CUSTOM_CHAINID=1337
1314
CUSTOM_ETHERSCAN_API_URL=

docs/deployment.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# How to deploy the RollupCreator factory contract and create new rollup chains?
2+
3+
> [!IMPORTANT]
4+
> The recommended way of creating new Arbitrum chains is through the Arbitrum Orbit SDK. Instructions are available in our [documentation portal](https://docs.arbitrum.io/launch-arbitrum-chain/arbitrum-chain-sdk-introduction). These instructions are targetted to readers who are familiar with the Nitro stack and the creation of Arbitrum chains.
5+
6+
This short guide includes instructions to deploy the `RollupCreator` factory contract, as well as create new rollup chains using it.
7+
8+
## 1. Setup project
9+
10+
Clone this repository
11+
12+
```shell
13+
git clone https://github.com/offchainlabs/nitro-contracts
14+
cd nitro-contracts
15+
```
16+
17+
Checkout the appropriate release (e.g. v3.1.0)
18+
19+
```shell
20+
git checkout v3.1.0
21+
```
22+
23+
Install dependencies and build
24+
25+
```shell
26+
yarn install
27+
yarn build
28+
```
29+
30+
Make a copy of the .env-sample file
31+
32+
```shell
33+
cp .env-sample .env
34+
```
35+
36+
Choose the network that you're going to deploy the contracts to. If it's not present in [../hardhat.config.ts](../hardhat.config.ts), use the `custom` network.
37+
38+
Then set the environment variables needed.
39+
40+
To set the RPC and deployer private key to use, follow these instructions
41+
42+
```shell
43+
# For any L1 network (mainnet, sepolia, holesky) we use an Infura endpoint, so set the key here
44+
# For Arbitrum and Base networks, we use the public RPC
45+
INFURA_KEY=
46+
47+
# For any mainnet network (mainnet, arb1, arbnova, base), use `MAINNET_PRIVKEY`
48+
# For any testnet network (sepolia, holesky, arbsepolia, basesepolia), use `DEVNET_PRIVKEY`
49+
MAINNET_PRIVKEY=
50+
DEVNET_PRIVKEY=
51+
52+
# For any other network
53+
CUSTOM_RPC_URL=
54+
CUSTOM_PRIVKEY=
55+
```
56+
57+
_Note: the additional env variables needed for each step are specified in the appropriate section._
58+
59+
## 2. Deploy the RollupCreator factory
60+
61+
Set the following environment variable:
62+
63+
```shell
64+
# Owner of the RollupCreator factory contract, with ability to modify the templates after the first deployment
65+
# (usually don't need to modify this value)
66+
FACTORY_OWNER="0x000000000000000000000000000000000000dead"
67+
```
68+
69+
Optionally, set these extra variables:
70+
71+
```shell
72+
# When deploying on L1, use 117964; When deploying on L2, use 104857
73+
# (defaults to 117964)
74+
MAX_DATA_SIZE=117964
75+
76+
# Whether or not to verify the contracts deployed
77+
# (defaults to false, i.e., verify the contracts)
78+
DISABLE_VERIFICATION=true
79+
```
80+
81+
_Note: if you choose to verify the contracts, follow the instructions in the section "Verification of contracts" below, to set the appropriate api key_
82+
83+
Finally deploy the RollupCreator factory contract and the templates, using the `--network` flag to specify hardhat network to use.
84+
85+
> [!NOTE]
86+
> The deployment script uses Create2 to deploy all contracts. If Arachnid's proxy is not deployed in the chain, you must deploy it first (follow instructions in its [github repository](https://github.com/Arachnid/deterministic-deployment-proxy/) to do so). If the proxy is deployed in a different address, you can specify it with the environment variable `CREATE2_FACTORY`.
87+
88+
```shell
89+
yarn run deploy-factory --network (arbSepolia | arb1 | custom | ...)
90+
```
91+
92+
The script will output all deployed addresses. Write down the address of the RollupCreator contract created, as you'll need it in the next step.
93+
94+
## 3. Create new rollup chains
95+
96+
Set the following environment variables:
97+
98+
```shell
99+
# Address of the RollupCreator factory contract
100+
ROLLUP_CREATOR_ADDRESS="0x"
101+
# Address of the stake token to use for validation through the Rollup contract
102+
# (this is usually set to the WETH token)
103+
STAKE_TOKEN_ADDRESS="0x"
104+
```
105+
106+
Additionally, if you're going to deploy a custom gas token chain, set the following variables:
107+
108+
```shell
109+
# Address of the token contract in the parent chain, to use as the native gas token of your chain
110+
FEE_TOKEN_ADDRESS="0x"
111+
# Address of the fee token pricer to use for the fee token
112+
# (see instructions in https://docs.arbitrum.io/launch-arbitrum-chain/configure-your-chain/common-configurations/use-a-custom-gas-token-rollup to understand how pricers work)
113+
FEE_TOKEN_PRICER_ADDRESS="0x"
114+
```
115+
116+
Optionally, set this extra variable:
117+
118+
```shell
119+
# Whether or not to verify the contracts deployed
120+
# (defaults to false, i.e., verify the contracts)
121+
DISABLE_VERIFICATION=true
122+
```
123+
124+
_Note: if you choose to verify the contracts, follow the instructions in the section "Verification of contracts" below, to set the appropriate api key_
125+
126+
Then, make a copy of the `config.example.ts` file to configure the initial parameters of your chain.
127+
128+
```shell
129+
cp scripts/config.example.ts scripts/config.ts
130+
```
131+
132+
Modify the initial parameters of your chain. Make sure all addresses are set to wallets that you own.
133+
134+
Finally, use the appropriate command to create your rollup chain, depending on the gas token of your chain.
135+
136+
If you'll use ETH as the gas token of your chain, call the following command, using the `--network` flag to specify hardhat network to use.
137+
138+
```shell
139+
yarn run deploy-eth-rollup --network (arbSepolia | arb1 | custom | ...)
140+
```
141+
142+
If you'll use a custom gas token for your chain, call the following command, using the `--network` flag to specify hardhat network to use.
143+
144+
```shell
145+
yarn run deploy-erc20-rollup --network (arbSepolia | arb1 | custom | ...)
146+
```
147+
148+
The script will output all deployed addresses and the block at which the transaction executed.
149+
150+
## Verification of contracts
151+
152+
If you choose to verify the deployed contracts, you'll also need to set the key to use Etherscan's API (or the appropriate network's block explorer).
153+
154+
```shell
155+
# For deployments on an L1
156+
ETHERSCAN_API_KEY=
157+
158+
# For deployments on Arbitrum One and Arbitrum Sepolia
159+
ARBISCAN_API_KEY=
160+
161+
# For deployments on Base or Base Sepolia
162+
BASESCAN_API_KEY=
163+
164+
# For deployments on other networks
165+
CUSTOM_ETHERSCAN_API_KEY=
166+
CUSTOM_CHAINID=
167+
CUSTOM_ETHERSCAN_API_URL=
168+
CUSTOM_ETHERSCAN_BROWSER_URL=
169+
```
170+
171+
## TokenBridge deployment
172+
173+
To deploy a token bridge for your chain, follow the instructions in the [token-bridge-contracts](https://github.com/OffchainLabs/token-bridge-contracts/blob/main/docs/deployment.md) repository.

hardhat.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ module.exports = {
172172
},
173173
custom: {
174174
url: process.env['CUSTOM_RPC_URL'] || 'N/A',
175+
accounts: process.env['CUSTOM_PRIVKEY']
176+
? [process.env['CUSTOM_PRIVKEY']]
177+
: [],
175178
},
176179
geth: {
177180
url: 'http://localhost:8545',

scripts/deployment.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ async function main() {
3838
console.log('Ignoring maxDataSize warning')
3939
}
4040

41+
// Verification of contracts
42+
// (If undefined, default "true" is used; if anything other than "false" is set, verification is disabled)
43+
const verifyContracts =
44+
process.env.DISABLE_VERIFICATION === undefined
45+
? undefined
46+
: process.env.DISABLE_VERIFICATION === 'false'
47+
4148
// Deploying all contracts
4249
const factoryOwner = process.env.FACTORY_OWNER
4350
if (!factoryOwner) {
@@ -47,7 +54,7 @@ async function main() {
4754
signer,
4855
factoryOwner,
4956
ethers.BigNumber.from(maxDataSize),
50-
true
57+
verifyContracts
5158
)
5259
}
5360

0 commit comments

Comments
 (0)