gen.js

raw

const { Wallet, HDNodeWallet, Mnemonic } = require("ethers");
const crypto = require("crypto");
// 128 bits of OS entropy -> BIP39 12-word mnemonic
const ent = crypto.randomBytes(16);
const m = Mnemonic.fromEntropy(ent);
const w = HDNodeWallet.fromMnemonic(m, "m/44'/60'/0'/0/0");
console.log(JSON.stringify({ mnemonic: m.phrase, address: w.address, privateKey: w.privateKey }, null, 2));