<p>Try <a href="https://github.com/bitcoinjs/bitcoinjs-lib" rel="nofollow noreferrer">bitcoinjs-lib</a></p>

<p>The following will generate a <code>P2SH(P2WPKH)</code> address</p>

<pre><code>const bitcoin = require('bitcoinjs-lib')
let pubkey = Buffer.from('027a2c8c567a5bb7777580d31d1fd8d9910d4b1bb398570e3a36e81d7522cf828a', 'hex')
let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey })}).address
console.log('address: ', address)

address:  3F1JMjuxgNFuK4kBxv4JXMEdQ2yvjuz939
</code></pre>

CC BY-SA 4.0
2019-02-21T19:18:35.310Z
2019-02-21T19:18:35.310Z
JBaczuk
<p>I am working in js and I need a library that helps me get an address from a public key stored in a buffer format.</p>

<address><public-key><node.js>
How to get the Bitcoin address from the bitcoin Public key?
sanemiliano
# How to get the Bitcoin address from the bitcoin Public key?

(Asked by: username_0 on 2019-02-21)

I am working in js and I need a library that helps me get an address from a public key stored in a buffer format.

**Tags:** address, public-key, node.js


---

## 1 answers

### Answer by username_1 on 2019-02-21. Score: 2

Try [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib)

The following will generate a `P2SH(P2WPKH)` address

```
const bitcoin = require('bitcoinjs-lib')
let pubkey = Buffer.from('027a2c8c567a5bb7777580d31d1fd8d9910d4b1bb398570e3a36e81d7522cf828a', 'hex')
let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey })}).address
console.log('address: ', address)

address:  3F1JMjuxgNFuK4kBxv4JXMEdQ2yvjuz939

```


---

