0

I have question

Is it possible to get address and private key from mnemonic code??

For example) I created address (0x12345) and I receive mnemonic code such as apple bed bad rice

If i know mnemonic code (apple bed bad rice), Can i get 0x12345 address ??

josep
  • 105
  • 2
  • 5

1 Answers1

0

yes this is possible via ethers.js. Run the following piece of code in nodejs environment:

const ethers = require('ethers');

async function init() {
    //creating new random mnemonic
    //const mnemonic = await ethers.utils.HDNode.entropyToMnemonic(ethers.utils.randomBytes(16));
    const mnemonic = 'YOUR_MNEMONIC_WORDS';

    //mnemonic to private, public key and address
    const wallet = ethers.Wallet.fromMnemonic(mnemonic);
}
init();

If you need this logic on website you will have to use browserify, because browsers don't have the require method defined.

Miroslav Nedelchev
  • 3,519
  • 2
  • 10
  • 12