Hi i am new to bitcoin all i want to know is how to generate address using mnemonic seed?

let testnet =Bitcoin.networks.testnet;
let keypair =Bitcoin.ECPair.makeRandom({network:testnet});
let address=keypair.getAddress();
let privateKey=keypair.toWIF();
res.json("Public Address  "+ address+ "  "+privateKey)

3 Answers 3


Using bitcoinjs-lib and bip39. You can install those with npm install bitcoinjs-lib bip39 --save

const Bitcoin = require('bitcoinjs-lib');
const Bip39 = require('bip39');
const Bip32 = require('bip32');

function getAddress (node, network) {
  return Bitcoin.payments.p2pkh({ pubkey: node.publicKey, network }).address

const mnemonic = `entire taste skull already invest view turtle surge razor key next \
buffalo venue canoe sheriff winner wash ten subject hamster scrap unit shield garden`;

const seed = Bip39.mnemonicToSeed(mnemonic);

const root = Bip32.fromSeed(seed, Bitcoin.networks.bitcoin);

const child1 = root.derivePath("m/44'/0'/0'/0/0");
const child2 = root.deriveHardened(44).deriveHardened(0).deriveHardened(0).derive(0).derive(0);

console.log(getAddress(child1)); //1ENQm8nEP7sd6dqXbAMYZ4AuqcP8Y7AtR
console.log(getAddress(child2)); //1Hb6Z1uZ1RuZ6GXTvedQ2ETYKYsMc5qynN

You can check the code is working using this website. You might also want to read up a little about BIP32, BIP39 and BIP44. An executive summary below:

  • The BIP32 describes how you can generate new child keys programmatically from a single key and a few other properties.

  • BIP39 defines a set of standard words used to mimic a key and how to transform them back to the original "seed" (the key from BIP32).

  • BIP44 specifies how you should compute the child keys from the parent one. You can see from my code that I used derivePath("m/44'/0'/0'/0/0"); in conformance of its specification.

  • Does the GUI have a way?
    – caveman
    Jul 25, 2021 at 0:32

Here's the complete code to run everything from your browser:

# call this {anything}.sh
# when finished, run chmod +x *.sh
# then ./*.sh should execute the script 
# Create a ECDSA keypair for use with crypto currencies
# The key will be derived from whatever seed phrase is entered by the user
# Copyright (c) 2019 B Tasker

read -p "Enter a seed sentence: " seedphrase

# Derive a private key
privkey=$(echo "$seedphrase" | openssl sha256 | cut -d\  -f2)

# Get a proper copy of the private key
privkeyfull=$(openssl ec -inform DER -in <(cat <(echo -n "302e0201010420") <(echo -n "$privkey") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null)

# Now start creating the pub key 
longpub=$(openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "$privkey") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null  | tail -6 | head -5 | sed 's/[ :]//g' | tr -d '\n' && echo)

# Create the compressed version
compub=$(echo -n "$longpub" | cut -c1-66 | sed 's/^04/02/')

# Now RipeMD it:
hash256=$(echo "$compub" | xxd -r -p | openssl sha256 | cut -d\  -f2)
ripemd=$(echo "$hash256" | xxd -r -p | openssl ripemd160 | cut -d\  -f2)

# Now RipeMD the uncompressed :
hash256=$(echo "$longpub" | xxd -r -p | openssl sha256 | cut -d\  -f2)
ripemdunc=$(echo "$hash256" | xxd -r -p | openssl ripemd160 | cut -d\  -f2)

# And a version we can pass into OpenSSL if we need to
pubkeyfull=$(openssl ec -inform DER -in <(cat <(echo -n "302e0201010420") <(echo -n "e359ae12b3c49fa0d59d0947a97acc9d8595017205909a883501ae09d4ea1888") <(echo -n "a00706052b8104000a") | xxd -r -p) -pubout 2>/dev/null)

cat << EOM
Seed Phrase: 


Private: $privkey
Long public: $longpub
Compressed Public: $compub
RipeMD (Compressed) Public: $ripemd
RipeMD (Uncompressed) Public: $ripemdunc



Keep these safe

It is simpler than you think using command lines. Look at https://github.com/libbitcoin/libbitcoin-system/wiki/Altcoin-Version-Mappings#7-bitcoin-btc-bip-3944-technology-examples.


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.