Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Prompt questions for generating the genesis file and creating the rollup
  • Loading branch information
TucksonDev committed Nov 6, 2025
commit aa7e0af43a7283f3d34c37a2ee588346eaec4bef
2 changes: 0 additions & 2 deletions examples/generate-genesis-file/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ NITRO_NODE_IMAGE=offchainlabs/nitro-node:v3.7.4-9244576
#################################
# Rollup creation configuration #
#################################
CREATE_ROLLUP=true

# Required
DEPLOYER_PRIVATE_KEY=

Expand Down
53 changes: 44 additions & 9 deletions examples/generate-genesis-file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils';
import { config } from 'dotenv';
import { execSync } from 'child_process';
import * as fs from 'fs';
import { createInterface } from 'readline';
config();

// Env variables check
Expand Down Expand Up @@ -41,17 +42,47 @@ function withFallbackPrivateKey(privateKey: string | undefined): `0x${string}` {
return sanitizePrivateKey(privateKey);
}

async function askQuestion(question: string): Promise<string> {
const rl = createInterface({
input: process.stdin,
output: process.stdout,
});

return new Promise((resolve) =>
rl.question(question, (answer: string) => {
rl.close();
resolve(answer);
}),
);
}

async function main() {
// Step 0 - Build genesis file generator container from Github
// Step 0 - Check if there's a genesis.json file present in the directory
let generateGenesisFile = true;
if (fs.existsSync('genesis.json')) {
// Ask the user if they want to overwrite the existing file
const generateGenesisuserResponse = await askQuestion(
'A genesis.json file already exists in the current directory. Do you want to overwrite it? (y/n): ',
);
if (generateGenesisuserResponse.toLowerCase() !== 'y') {
generateGenesisFile = false;
console.log('Using existing genesis.json file.');
}
}

// Step 1 - If needed, generate the genesis file
// Note: remove this step once we have a public image
console.log(`Build genesis file generator container...`);
execSync(
`docker build -t genesis-file-generator https://github.com/OffchainLabs/genesis-file-generator.git#containerization`,
);
if (generateGenesisFile) {
// Build genesis file generator container from Github
console.log(`Build genesis file generator container...`);
execSync(
`docker build -t genesis-file-generator https://github.com/OffchainLabs/genesis-file-generator.git#containerization`,
);

// Step 1 - Generate genesis file
console.log(`Generate genesis file...`);
execSync(`docker run --env-file ./.env genesis-file-generator > genesis.json`);
// Generate genesis file
console.log(`Generate genesis file...`);
execSync(`docker run --env-file ./.env genesis-file-generator > genesis.json`);
}

// Step 2 - Obtain genesis block hash and sendRoot hash
console.log(`Obtain genesis block hash and sendRoot hash...`);
Expand All @@ -76,7 +107,11 @@ async function main() {
console.log(`SendRoot hash: ${sendRootHash}`);

// Step 4 - Create Rollup (optional)
if (process.env.CREATE_ROLLUP === 'true') {
// Ask the user if they want to create a rollup
const createRollupUserResponse = await askQuestion(
'Do you want to continue creating the rollup with the current genesis.json file? (y/n)',
);
if (createRollupUserResponse.toLowerCase() === 'y') {
// load or generate a random batch poster account
const batchPosterPrivateKey = withFallbackPrivateKey(process.env.BATCH_POSTER_PRIVATE_KEY);
const batchPoster = privateKeyToAccount(batchPosterPrivateKey).address;
Expand Down
Loading