Skip to content

Instantly share code, notes, and snippets.

@kvhnuke
Created January 31, 2019 02:20
Show Gist options
  • Save kvhnuke/59e9b04ca3edbaa557f135e9c5e63a4a to your computer and use it in GitHub Desktop.
Save kvhnuke/59e9b04ca3edbaa557f135e9c5e63a4a to your computer and use it in GitHub Desktop.
Generate 200 million eth account genesis
const fs = require("fs");
var JSONStream = require("JSONStream");
var LIMIT = 200000000;
var transformStream = JSONStream.stringifyObject(
'{"config":{"chainId":15,"homesteadBlock":0,"eip155Block":0,"eip158Block":0},"difficulty":"20","gasLimit":"2100000","alloc":{',
",",
"}}"
);
var outputStream = fs.createWriteStream("./sample-genesis.json");
transformStream.pipe(outputStream);
const gen = () => {
var ok = true;
do {
LIMIT--;
if (LIMIT % 100000 === 0) console.log(LIMIT);
if (LIMIT === 0) {
transformStream.write([
Number(LIMIT)
.toString(16)
.padStart(40, "0"),
{
balance: "30000000000000000000"
}
]);
transformStream.end();
} else {
ok = transformStream.write([
Number(LIMIT)
.toString(16)
.padStart(40, "0"),
{
balance: "30000000000000000000"
}
]);
}
} while (LIMIT > 0 && ok);
if (LIMIT > 0) {
transformStream.once("drain", gen);
}
};
gen();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment