|
| 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. |
0 commit comments