How to Deploy a Rollup chain using the Orbit SDK
This document explains how to use the Orbit SDK to deploy a Rollup Orbit chain
.
This document is under construction and may change significantly as we incorporate style guidance and feedback from readers. Feel free to request specific clarifications by clicking the Request an update
button at the top of this document.
See the "create-rollup-eth" example in the Orbit SDK repository for additional guidance.
The main benefit of the Orbit SDK lies in facilitating the deployment and fine-tuning of Orbit chains core Smart-Contracts.
These contracts are deployed on parent chains
, they are:
- Rollup contracts
- Bridge contracts
- Contracts handling fraud proofs
Core contracts are the backbone of Arbitrum's Nitro stack, ensuring its robust and efficient operation. You can explore their code in the nitro-contracts GitHub repository.
Rollup deployment parameters
createRollup
is the function that will deploy your core contracts on the parent chain.
createRollup
takes a complex input named deployParams
, which defines the characteristics of an Orbit Rollup chain.
The following will walk you through the methods and properties you will use to configure your chain.
1. RollupDeploymentParams struct
struct RollupDeploymentParams {
Config config;
address[] validators;
uint256 maxDataSize;
address nativeToken;
bool deployFactoriesToL2;
uint256 maxFeePerGasForRetryables;
address[] batchPosters;
address batchPosterManager;
}
This Solidity struct includes key settings like the chain configuration (Config
), validator addresses, maximum data size, the native token of the chain, and more.
2. Config struct
struct Config {
uint64 confirmPeriodBlocks;
uint64 extraChallengeTimeBlocks;
address stakeToken;
uint256 baseStake;
bytes32 wasmModuleRoot;
address owner;
address loserStakeEscrow;
uint256 chainId;
string chainConfig;
uint64 genesisBlockNum;
ISequencerInbox.MaxTimeVariation sequencerInboxMaxTimeVariation;
}
The Config
struct defines the chain's core settings, including block confirmation periods, stake parameters, and the chain ID.
3. MaxTimeVariation struct
struct MaxTimeVariation {
uint256 delayBlocks;
uint256 futureBlocks;
uint256 delaySeconds;
uint256 futureSeconds;
}
This nested struct within Config
specifies time variations related to block sequencing, providing control over block delay and future block settings.
4. chainConfig
The chainConfig
parameter within the Config
struct allows you to customize your Orbit chain. It's a stringified JSON
object containing various configuration options that dictate how the Orbit chain behaves and interacts with the parent chain network.
Here's a brief overview of chainConfig
:
{
chainId: number;
homesteadBlock: number;
daoForkBlock: null;
daoForkSupport: boolean;
eip150Block: number;
eip150Hash: string;
eip155Block: number;
eip158Block: number;
byzantiumBlock: number;
constantinopleBlock: number;
petersburgBlock: number;
istanbulBlock: number;
muirGlacierBlock: number;
berlinBlock: number;
londonBlock: number;
clique: {
period: number;
epoch: number;
};
arbitrum: {
EnableArbOS: boolean;
AllowDebugPrecompiles: boolean;
DataAvailabilityCommittee: boolean;
InitialArbOSVersion: number;
InitialChainOwner: Address;
GenesisBlockNum: number;
MaxCodeSize: number;
MaxInitCodeSize: number;
};
}
Out of chainConfig
's parameters, a few are particularly important and are likely to be configured by the chain owner: chainId
, arbitrum.InitialChainOwner
, arbitrum.InitialArbOSVersion
, arbitrum.DataAvailabilityCommittee
, arbitrum.MaxCodeSize
, and arbitrum.MaxInitCodeSize
.
4.1. prepareChainConfig
For easier config preparation, the Orbit SDK provides the prepareChainConfig
function, which takes config parameters as arguments and returns a full chainConfig
. Any parameters not provided will default to standard values, which are detailed here.
Here are the parameters you can use with prepareChainConfig
:
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
chainId | Number | Yes | / | Your chain's unique identifier. It differentiates your chain from others in the ecosystem. |
arbitrum.InitialChainOwner | Address | Yes | / | Specifies who owns and controls the chain. |
arbitrum.InitialArbOSVersion | Number | No | latest | Specifies which version of ArbOS should the chain run. |
arbitrum.DataAvailabilityCommittee | Boolean | No | false | When set to false , your chain will run as a Rollup chain, and when set to true it will run as an AnyTrust chain. |
arbitrum.MaxCodeSize | Number | No | 24,576 (bytes) | Sets the maximum size for contract bytecodes on the chain. |
arbitrum.MaxInitCodeSize | Number | No | 49,152 (bytes) | Similar to arbitrum.MaxCodeSize , defines the maximum size for your chain's initialization code. |
Below is an example of how to use prepareChainConfig
to set up a Rollup chain with a specific chainId
, an InitialChainOwner
(named as deployer
):
import { prepareChainConfig } from '@arbitrum/orbit-sdk';
const chainConfig = prepareChainConfig({
chainId: 123_456,
arbitrum: {
InitialChainOwner: deployer,
DataAvailabilityCommittee: false,
},
});