3

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)
1
  • have you been able to find a solution?
    – Anonymous
    Sep 5, 2021 at 17:52

2 Answers 2

1

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 use m/44'/60'/0'/0/1, then m/44'/60'/0'/0/2 ...

0

You can also use ethers.js for this. See: https://docs.ethers.io/ethers.js/html/api-wallet.html#wallet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.