<p>Try using the <code>bip32</code> module. Also there are a few other things you'll need to fix as well. See <a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js#L86" rel="nofollow noreferrer">Use BIP39 to generate BIP32 addresses</a>. Note, this will generate a <code>P2PKH</code> address, see <code>getAddress()</code> function.</p>

<p><strong>index.js:</strong></p>

<pre><code>'use strict'

var bip39 = require('bip39');
var bip32 = require('bip32');
var bitcoin = require('bitcoinjs-lib');

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

var mnemonic = bip39.generateMnemonic();
if (bip39.validateMnemonic(mnemonic)) {
    console.log('\nThe mnemonic is \n' + mnemonic);
    var seed = bip39.mnemonicToSeed(mnemonic);
    var root = bip32.fromSeed(seed);
    var dp = root.derivePath("m/140'/0'/0'/0/5");

    console.log('\nThe Address is \n' + getAddress(dp));    
} else {

}
</code></pre>

<p><strong>Output:</strong></p>

<pre><code>$ node index.js

The mnemonic is
assume victory kiwi swarm furnace firm thumb exact dizzy crucial neglect certain

The Address is
1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T
</code></pre>

CC BY-SA 4.0
2018-10-18T08:07:46.143Z
Hi @JBaczuk help to get privatekey for this address 1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T........ from the above process I got address but I do't get any way to get privatekey
Ishwar Chandra Tiwari
CC BY-SA 4.0
2018-10-18T11:35:04.667Z
Try `dp.privateKey`
JBaczuk
CC BY-SA 4.0
2018-09-12T19:28:19.923Z
2018-09-12T19:28:19.923Z
JBaczuk
<p>I am getting Getting error at this line<br>
<strong>var root = bitcoin.HDNode.fromSeedBuffer(seed);</strong></p>

<blockquote>
  <p>UnhandledPromiseRejectionWarning: TypeError: Cannot read property
  'fromSeedBuffer' of undefined</p>
</blockquote>

<p>Here is the code snippet to generate bitcoin address:</p>

<pre><code>'use strict'

var bip39 = require('bip39');
var bitcoin = require('bitcoinjs-lib');

var mnemonic = bip39.generateMnemonic();
if (bip39.validateMnemonic(mnemonic)) {
    console.log('\nThe mnemonic is \n' + mnemonic);
    var seed = bip39.mnemonicToSeed(mnemonic);
    var root = bitcoin.HDNode.fromSeedBuffer(seed);
    var dp = root.derivePath("m/140'/0'/0'/0/5");

    console.log('\nThe Address is \n' + dp.getAddress());    
} else {

}
</code></pre>

<p>Where bitcoinjs-lib v4.0.0 and 
      bip39 v2.5.0 and node v8.0</p>

<javascript><bitcoinjs><mnemonic-seed><node.js>
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fromSeedBuffer' of undefined
Ishwar Chandra Tiwari
# UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fromSeedBuffer' of undefined

(Asked by: username_0 on 2018-09-12)

I am getting Getting error at this line  
**var root = bitcoin.HDNode.fromSeedBuffer(seed);**

> UnhandledPromiseRejectionWarning: TypeError: Cannot read property
> 'fromSeedBuffer' of undefined

Here is the code snippet to generate bitcoin address:

```
'use strict'

var bip39 = require('bip39');
var bitcoin = require('bitcoinjs-lib');

var mnemonic = bip39.generateMnemonic();
if (bip39.validateMnemonic(mnemonic)) {
    console.log('\nThe mnemonic is \n' + mnemonic);
    var seed = bip39.mnemonicToSeed(mnemonic);
    var root = bitcoin.HDNode.fromSeedBuffer(seed);
    var dp = root.derivePath("m/140'/0'/0'/0/5");

    console.log('\nThe Address is \n' + dp.getAddress());    
} else {

}

```

Where bitcoinjs-lib v4.0.0 and
bip39 v2.5.0 and node v8.0

**Tags:** javascript, bitcoinjs, mnemonic-seed, node.js


---

## 1 answers

### Answer by username_1 on 2018-09-12. Score: 1 | Accepted answer

Try using the `bip32` module. Also there are a few other things you'll need to fix as well. See [Use BIP39 to generate BIP32 addresses](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js#L86). Note, this will generate a `P2PKH` address, see `getAddress()` function.

**index.js:**

```
'use strict'

var bip39 = require('bip39');
var bip32 = require('bip32');
var bitcoin = require('bitcoinjs-lib');

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

var mnemonic = bip39.generateMnemonic();
if (bip39.validateMnemonic(mnemonic)) {
    console.log('\nThe mnemonic is \n' + mnemonic);
    var seed = bip39.mnemonicToSeed(mnemonic);
    var root = bip32.fromSeed(seed);
    var dp = root.derivePath("m/140'/0'/0'/0/5");

    console.log('\nThe Address is \n' + getAddress(dp));    
} else {

}

```

**Output:**

```
$ node index.js

The mnemonic is
assume victory kiwi swarm furnace firm thumb exact dizzy crucial neglect certain

The Address is
1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T

```

> **Comments:**
> **username_0**: Hi @username_1 help to get privatekey for this address 1FYtPnUZZ2ZJL2fZ6XehGtkHfujUHkqK3T........ from the above process I got address but I do't get any way to get privatekey  
> **username_1**: Try `dp.privateKey`  

---

