Skip to content

Instantly share code, notes, and snippets.

@stabastian
Created April 16, 2019 15:36
Show Gist options
  • Save stabastian/1be41edfc52972ce0369fe71e90b1fd8 to your computer and use it in GitHub Desktop.
Save stabastian/1be41edfc52972ce0369fe71e90b1fd8 to your computer and use it in GitHub Desktop.
KeystoreV3 generator
const ethWallet = require('ethereumjs-wallet');
const bip39 = require('bip39');
const hdkey = require('ethereumjs-wallet/hdkey');
const mnemonic = bip39.generateMnemonic();
const hdWallet = hdkey.fromMasterSeed(bip39.mnemonicToSeedSync(mnemonic));
// get the firts account using the ethereum standard hd path.
const walletHdPath = "m/44'/60'/0'/0/0";
const wallet = hdWallet.derivePath(walletHdPath).getWallet();
const password = 'pass';
const address = wallet.getAddress().toString('hex');
const keystoreV3 = wallet.toV3String('pass');
const v3Wallet = ethWallet.fromV3(keystoreV3, password);
const privateKey = v3Wallet.getPrivateKey().toString('hex');
console.log("Mnemonic: " + mnemonic);
console.log("Address: 0x" + address);
console.log("Keystore: ", keystoreV3);
console.log("Private Key: ", privateKey);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment