Skip to main content

How to deploy a custom gas token chain using the Orbit SDK

RaaS providers

It is highly recommended to work with a Rollup-as-a-Service (RaaS) provider if you intend to deploy a production chain. You can find a list of RaaS providers here.

Creating a new Orbit chain involves deploying a set of contracts on your chain's parent chain. This page explains how to deploy a custom gas token Orbit chain using the Orbit SDK. See the Overview for an introduction to creating and configuring an Orbit chain.

Before reading this guide, we recommend:

info

Custom gas tokens are not supported yet on Rollup chains, only on AnyTrust chains.

About custom gas token Orbit chains

Custom gas token orbit chains let participants pay transaction fees in an ERC-20 token instead of ETH. Standard ERC-20 tokens can be used as gas tokens, while more complex tokens with additional functionality must fulfill these requirements to be used as gas tokens. The ERC-20 token to be used must be deployed on your chain's parent chain.

How to create a new custom gas token chain using the Orbit SDK

The deployment process for a custom gas token chain is very similar to that of an AnyTrust chain, but with some differences that we'll discuss in this guide.

Example script

The Orbit SDK includes an example script for creating a custom gas token Orbit chain. We recommend that you first understand the process described in this section and then check the create-rollup-custom-fee-token script.

Here are the steps involved in the deployment process:

  1. Create the chain's configuration object
  2. Deploy the custom gas token Orbit chain
  3. Understand the returned data
  4. Additional configuration

1. Create the chain's configuration object

The How to deploy a Rollup chain guide explains the configuration structure that we need to craft and send to the RollupCreator contract when we wish to create a new chain. We recommend that you familiarize yourself with that section before continuing.

Because we are deploying an AnyTrust chain, we must set the arbitrum.DataAvailabilityCommittee flag to true, to indicate that the chain will use a Data Availability Committee (DAC).

Below is an example of how to use createRollupPrepareDeploymentParamsConfig and the prepareChainConfig methods to craft the configuration needed:

import { createPublicClient, http } from 'viem';
import { createRollupPrepareDeploymentParamsConfig } from '@arbitrum/orbit-sdk';

const parentChainPublicClient = createPublicClient({
chain: parentChain,
transport: http(),
});

const createRollupConfig = createRollupPrepareDeploymentParamsConfig(parentChainPublicClient, {
chainId: 123_456,
owner: 0x123...890,
chainConfig: prepareChainConfig({
chainId: 123_456,
arbitrum: {
InitialChainOwner: 0x123...890,
DataAvailabilityCommittee: true,
},
}),
});

2. Deploy the custom gas token Orbit chain

With the crafted configuration, we can call the createRollup function, which will send the transaction to the RollupCreator contract and wait until it is executed.

However, before doing that, the owner needs to give allowance to the RollupCreator contract before starting the deployment process, so that it can spend enough tokens to send the correspondant Parent-to-Child messages during the deployment process. This process is handled within the createRollup function, but the owner must own enough tokens to create these messages.

Additionally, we'll pass the ERC-20 token to use as custom gas token in the nativeToken parameter of the createRollup function. We'll specify the address of the token contract in the parent chain.

Below is an example of how to use createRollup using the createRollupConfig crafted in the previous step, and the parameters mentioned above:

import { createPublicClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { createRollup } from '@arbitrum/orbit-sdk';

const deployer = privateKeyToAccount(deployerPrivateKey);
const parentChainPublicClient = createPublicClient({
chain: parentChain,
transport: http(),
});

const createRollupResults = await createRollup({
params: {
config: createRollupConfig,
batchPosters: [batchPoster],
validators: [validator],
nativeToken: '0xAddressInParentChain',
},
account: deployer,
parentChainPublicClient,
});

3. Understand the returned data

After calling createRollup, an object of type CreateRollupResults is returned with the following fields:

type CreateRollupResults = {
// The transaction sent
transaction: CreateRollupTransaction;
// The transaction receipt
transactionReceipt: CreateRollupTransactionReceipt;
// An object with the addresses of the contracts created
coreContracts: CoreContracts;
};

4. Additional configuration

Since custom gas token chains are AnyTrust chains, we'll also have to set the DAC keyset in the SequencerInbox. Refer to Set the DAC keyset in the SequencerInbox in the AnyTrust guide to learn how to do it.

5. Next step

Once the chain's contracts are created, you can move to the next step: configure your Orbit chain's node.