Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Publish NPM Package

on:
workflow_dispatch:
inputs:
version:
description: Base version to publish to npm, for example 1.0.2
required: true
type: string
tag:
description: Release channel
required: true
default: alpha
type: choice
options:
- alpha
- beta
- rc
- latest
prerelease:
description: Prerelease number for alpha, beta, or rc
required: false
default: '0'
type: string

jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
environment: publish
permissions:
id-token: write
contents: write
steps:
- name: Ensure main branch
if: github.ref != 'refs/heads/main'
run: |
echo "This workflow can only be run from main." >&2
exit 1

- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up pnpm
uses: pnpm/action-setup@v6

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: pnpm

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Resolve package version and npm dist-tag
env:
BASE_VERSION: ${{ inputs.version }}
RELEASE_CHANNEL: ${{ inputs.tag }}
PRERELEASE_NUMBER: ${{ inputs.prerelease }}
run: |
if [[ ! "$BASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version must be a numeric SemVer base version like 1.0.2." >&2
exit 1
fi

if [ "$RELEASE_CHANNEL" = "latest" ]; then
echo "NPM_PACKAGE_VERSION=$BASE_VERSION" >> "$GITHUB_ENV"
echo "NPM_DIST_TAG=latest" >> "$GITHUB_ENV"
else
if [[ ! "$PRERELEASE_NUMBER" =~ ^[0-9]+$ ]]; then
echo "Prerelease number must be a non-negative integer like 0 or 1." >&2
exit 1
fi
echo "NPM_PACKAGE_VERSION=$BASE_VERSION-$RELEASE_CHANNEL.$PRERELEASE_NUMBER" >> "$GITHUB_ENV"
echo "NPM_DIST_TAG=$RELEASE_CHANNEL" >> "$GITHUB_ENV"
fi

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Set package version
run: npm version "$NPM_PACKAGE_VERSION"

- name: Build package
run: pnpm build

- name: Pack package
run: NODE_AUTH_TOKEN="" npm publish --dry-run --tag "$NPM_DIST_TAG"

- name: Publish package
run: NODE_AUTH_TOKEN="" npm publish --tag "$NPM_DIST_TAG"

- name: Push version commit and tag
run: |
git push origin "HEAD:${GITHUB_REF_NAME}"
git push origin "v$NPM_PACKAGE_VERSION"
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ docs/

# Dotenv file
.env

# Dependency directories
node_modules/

# Output directories
dist/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
81 changes: 66 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,64 @@ cp .env.example .env
> [!NOTE]
> Make sure you set the correct values for the environment variables for your chain

Run the script (you must have `forge` (Foundry) and `jq` installed)
Choose one of the following options to generate the genesis file. The Docker option is the recommended path because it includes the required Foundry tooling.

### Option 1: Docker

Build the image and run the generator with your `.env` file. The generated JSON is written to `genesis/genesis.json`.

```shell
mkdir -p genesis
docker build -t genesis-file-generator .
docker run --rm \
--env-file .env \
-v "$(pwd)/genesis":/app/genesis \
genesis-file-generator
```

### Option 2: Shell

You must have `forge` (Foundry) and `jq` installed.

```shell
./generate.sh
```

The script will generate a genesis.json file in `genesis/genesis.json`.
### Option 3: Node.js

Use Node.js 24 or newer for the TypeScript-based generator tooling.

```shell
nvm use
pnpm install
pnpm generate
```

### Option 4: Importing the package

Use Node.js 24 or newer and install the package in your project. You must also have `forge` (Foundry) installed because the imported generator runs the Foundry script.

```ts
import { mkdirSync, writeFileSync } from 'node:fs';
import { generateGenesis } from '@arbitrum/genesis-file-generator';

const genesis = generateGenesis({
chainId: '12345',
arbosVersion: '40',
chainOwner: '0x0000000000000000000000000000000000000000',
l1BaseFee: '1000000000',
nitroNodeImage: 'offchainlabs/nitro-node:v3.9.5-66e42c4',
isAnyTrust: 'false',
loadDefaultPredeploys: 'true',
enableNativeTokenSupply: 'false',
enableTransactionFiltering: 'false',
});

mkdirSync('genesis', { recursive: true });
writeFileSync('genesis/genesis.json', `${JSON.stringify(genesis, null, 2)}\n`);
```

Each option generates a genesis.json file in `genesis/genesis.json`.

To calculate the BlockHash and SendRoot, run the genesis-generator tool from the Nitro node image separately:

Expand All @@ -62,18 +113,18 @@ BlockHash: 0xc8718e3eb62b1fab6ce0ee050385a545c21423a3b164a91545ad9e097fbd5341, S

This tool supports the following environment variables:

| Env variable | Description |
|------|-------------|
CHAIN_ID | Chain ID for the new chain
IS_ANYTRUST | Whether it's an Anytrust chain (true/false)
ARBOS_VERSION | ArbOS version to use
CHAIN_OWNER | Chain owner address
L1_BASE_FEE | Initial L1 base fee
ENABLE_NATIVE_TOKEN_SUPPLY | Whether to enable native token supply management in ArbOS (true/false)
ENABLE_TRANSACTION_FILTERING | Whether to enable transaction filtering in ArbOS (true/false)
NITRO_NODE_IMAGE | Nitro node Docker image
LOAD_DEFAULT_PREDEPLOYS | Whether to include default predeploys in the genesis file (true/false)
CUSTOM_ALLOC_ACCOUNT_FILE | Path to custom alloc account file for additional predeploys (optional)
| Env variable | Description |
| ---------------------------- | ---------------------------------------------------------------------- |
| CHAIN_ID | Chain ID for the new chain |
| IS_ANYTRUST | Whether it's an Anytrust chain (true/false) |
| ARBOS_VERSION | ArbOS version to use |
| CHAIN_OWNER | Chain owner address |
| L1_BASE_FEE | Initial L1 base fee |
| ENABLE_NATIVE_TOKEN_SUPPLY | Whether to enable native token supply management in ArbOS (true/false) |
| ENABLE_TRANSACTION_FILTERING | Whether to enable transaction filtering in ArbOS (true/false) |
| NITRO_NODE_IMAGE | Nitro node Docker image |
| LOAD_DEFAULT_PREDEPLOYS | Whether to include default predeploys in the genesis file (true/false) |
| CUSTOM_ALLOC_ACCOUNT_FILE | Path to custom alloc account file for additional predeploys (optional) |

### Custom alloc file format

Expand Down Expand Up @@ -689,7 +740,7 @@ Source code available at https://github.com/zerodevapp/kernel/blob/8f7fd9946b9d3
#### How to verify the creation bytecode and the target address

> [!NOTE]
> Even though the contract address is labeled as being for v3.1, it was actually compiled with a previous commit: `8f7fd9946b9d351bb5be0428bf34c87bad7ed6c9`.
> Even though the contract address is labeled as being for v3.1, it was actually compiled with a previous commit: `8f7fd9946b9d351bb5be0428bf34c87bad7ed6c9`.

Follow the build instructions of the repository and obtain the creation bytecode in the artifacts json file. Note that you must build the contracts using foundry with the following configuration:

Expand Down
Loading