<p>To get a balance of the address you need a view of the blockchain's current utxo set. This is typically done by syncing a node. I don't believe bitcoinjs has the capability to be a node (nor it is recomended to use it as one if it does).</p>
<p>Using bitcoin core you could add it to the wallet and do a rescan.</p>
<p>Alternatively you can use something that requires more trust and ping a block explorer. Bitcoinjs has an example on how to do this here <a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts#L10" rel="nofollow noreferrer">https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts#L10</a></p>

CC BY-SA 4.0
2021-12-01T03:13:24.373Z
const result = await dhttp({
        method: 'GET',
        url: 'https://blockchain.info/rawaddr/' + address,
      });

this part?
Moblize IT
CC BY-SA 4.0
2021-12-01T03:37:36.150Z
Also if you look at my question i am using a different blockchain https://diviproject.org
Moblize IT
CC BY-SA 4.0
2021-12-02T04:19:06.010Z
> const result = await dhttp({ method: 'GET', url: 'blockchain.info/rawaddr' + address, }); this part?

Yes
benthecarman
CC BY-SA 4.0
2021-11-30T23:43:27.773Z
2021-11-30T23:43:27.773Z
benthecarman
<p>So, first of all i will be creating these wallet addresses on my end using below code:</p>
<pre><code> const diviMainnet = {
                    messagePrefix: '\x19Divi Signed Message:\n',
                    bech32: 'divi',
                    bip32: {
                      public: 0x22d2533,
                      private: 0x221312b
                    },
                    pubKeyHash: 0x1e,
                    scriptHash: 0xd,
                    wif: 0xd4
                  }
                  const keyPair = ECPair.ECPair.makeRandom();
                  const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: diviMainnet });
</code></pre>
<p>I am storing the WIF as below</p>
<pre><code>     myWallet =     {
                    &quot;pubKey&quot;: address,
                    &quot;wif&quot;: keyPair.toWIF()
                  }
//save to db
</code></pre>
<p>now how do i check the balance of the above wallet at any point later?</p>
<p>I am using bitcoinjs library on nodejs.</p>

CC BY-SA 4.0
2021-12-20T19:27:48.967Z
Voting to close, because questions about altcoins are not on-topic for this site.
Murch
<balance><bitcoinjs>
How to read the balance on a wallet address
Moblize IT
# How to read the balance on a wallet address

(Asked by: username_0 on 2021-11-27)

So, first of all i will be creating these wallet addresses on my end using below code:

```
 const diviMainnet = {
                    messagePrefix: '\x19Divi Signed Message:\n',
                    bech32: 'divi',
                    bip32: {
                      public: 0x22d2533,
                      private: 0x221312b
                    },
                    pubKeyHash: 0x1e,
                    scriptHash: 0xd,
                    wif: 0xd4
                  }
                  const keyPair = ECPair.ECPair.makeRandom();
                  const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: diviMainnet });

```

I am storing the WIF as below

```
     myWallet =     {
                    "pubKey": address,
                    "wif": keyPair.toWIF()
                  }
//save to db

```

now how do i check the balance of the above wallet at any point later?

I am using bitcoinjs library on nodejs.

**Tags:** balance, bitcoinjs

> **Comments:**
> **username_1**: Voting to close, because questions about altcoins are not on-topic for this site.  

---

## 1 answers

### Answer by username_2 on 2021-11-30. Score: 3

To get a balance of the address you need a view of the blockchain's current utxo set. This is typically done by syncing a node. I don't believe bitcoinjs has the capability to be a node (nor it is recomended to use it as one if it does).

Using bitcoin core you could add it to the wallet and do a rescan.

Alternatively you can use something that requires more trust and ping a block explorer. Bitcoinjs has an example on how to do this here <https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts#L10>

> **Comments:**
> **username_0**: const result = await dhttp({         method: 'GET',         url: 'https://blockchain.info/rawaddr/' + address,       });  this part?  
> **username_0**: Also if you look at my question i am using a different blockchain https://diviproject.org  
> **username_2**: > const result = await dhttp({ method: 'GET', url: 'blockchain.info/rawaddr' + address, }); this part?  Yes  

---

