how to generate multiple addresses from single mnemonic?
var hdkey = require("ethereumjs-wallet/hdkey")
var bip39 = require("bip39");
// You can generate a mnemonic seed with bip39 library
var mnemonic = "seed sock milk ";
var path = "m/44'/60'/0'/0/0";
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));
var wallet = hdwallet.derivePath(path).getWallet();
var address = "0x" + wallet.getAddress().toString("hex");
console.log(address)
Best Answer
This is an old question but since no answer: the last number of the derivation path is to be changed to generate a new address: 0 is the first address, that you get with path
m/44'/60'/0'/0/0
, then usem/44'/60'/0'/0/1
, thenm/44'/60'/0'/0/2
...