I've been unable to generate the Account I see in MetaMask in EthereumJSWallet even if I use the same mnemonic.

Due to the lack of documentation, I may be misunderstanding how to do so. I have run the following 2 code-blocks in a Truffle Node console in my Terminal but I never got the correct result.

The variable mnemonic holds my MetaMask 12 word string. Per the HD Wallet API section of the EthereumJSWallet docs, I should "use bip39 to create [a seed] from a BIP39 mnemonic." However, I'm still unable to generate the appropriate account.

Neither wallet_test nor any of the derived paths in either of the 2 code-snippets below correspond to my first account.

Attempt 1:

var seed = bip39.mnemonicToSeed(mnemonic)
var wallet_test = hdkey.fromMasterSeed(seed)

Attempt 2:

var seed = bip39.mnemonicToSeedHex(mnemonic)
var wallet_test = hdkey.fromMasterSeed(seed)

Any help please?

1 Answer 1


This code will generate the same address from the mnemonic that MetaMask, MyEtherWallet, etc

const bip39 = require('bip39');
const hdkey = require('ethereumjs-wallet/hdkey');

const mnemonic = 'party box feel talent peace tiger endorse defy cheese girl tumble mail';
const seed = bip39.mnemonicToSeed(mnemonic);

const hdwallet = hdkey.fromMasterSeed(seed);
const myWallet = hdwallet.derivePath("m/44'/60'/0'/0/0").getWallet();

console.log(`Address: ${myWallet.getAddressString()}`);
console.log(`Private Key: ${myWallet.getPrivateKeyString()}`);

It doesn't add the checksum to the address

  • 0x999c43b9dd689b9a0bf12ce097663857f62ffbe7 without checksum
  • 0x999C43B9DD689b9a0bF12Ce097663857f62ffbe7 with checksum
  • how to use same code in flutter, Mar 26, 2019 at 16:24
  • @IshwarChandraTiwari Sorry, but I've never used flutter. It is better if you ask a a new question about that.
    – Ismael
    Mar 26, 2019 at 16:32
  • To generate a seed you need a mnemonic and a password. In the above code, What is used for the password in the code above? Is it generated internally within the line "bip39.mnemonicToSeed(mnemonic)"? Mar 14, 2020 at 6:32
  • @VedaSadhak There's an optional second parameter in bip39.mnemonicToSeed(mnemonic, *password*). It is assumed to be an empty string if none is provided.
    – Ismael
    Mar 14, 2020 at 13:40

Your Answer

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

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