Skip to content

Instantly share code, notes, and snippets.

View kot-begemot's full-sized avatar

Max Zab kot-begemot

  • TotalSig
  • Tallinn, Estonia
View GitHub Profile
@kot-begemot
kot-begemot / ethereumHD.js
Created December 31, 2021 13:28 — forked from Meshugah/ethereumHD.js
Sample HD wallet for Ethereum
const bip39 = require("bip39"); // mnemonic generator
const hdkey = require("hdkey"); // wallet lib
const ethUtil = require("ethereumjs-util"); // Used here for public address and public key generation
const mnemonic = bip39.generateMnemonic(); // generates string
const seed = bip39.mnemonicToSeedSync(mnemonic).toString('hex'); // creates seed for wallet
const root = hdkey.fromMasterSeed(seed);
const masterPrivateKey = root.privateKey.toString('hex');