<p>Since you mentioned PHP you can install a Bitcoin Node on your server and then use EasyBitcoin-PHP: <a href="https://github.com/aceat64/EasyBitcoin-PHP" rel="nofollow noreferrer">https://github.com/aceat64/EasyBitcoin-PHP</a> </p>

<p>Then use the Bitcoin API:
<a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list</a></p>

<p>To list all transactions associated with an account:</p>

<pre><code>echo $bitcoin-&gt;getreceivedbyaddress($btc_address);
</code></pre>

<p>"Returns the amount received by  in transactions with at least [minconf] confirmations. It correctly handles the case where someone has sent to the address in multiple transactions. Keep in mind that addresses are only ever used for receiving transactions. Works only for addresses in the local wallet, external addresses will always show 0."</p>

<p>So you could run this and compare with your DB to see if a new transaction appears that isn't already in the DB.</p>

<p>--</p>

<p>To monitor a balance of an account you can just check on each page load (and update your DB if you wanted to):</p>

<pre><code>echo $bitcoin-&gt;getbalance($user['id'], 1);
</code></pre>

<p>Get one of your users addresses:</p>

<pre><code>echo $bitcoin-&gt;getaccount($user['id']);
</code></pre>

<p>To check transactions:</p>

<pre><code>echo $bitcoin-&gt;gettransaction($trans_id);
</code></pre>

<p>--</p>

<p>You could also use an API:
<a href="https://bitcoin.stackexchange.com/questions/51794/how-to-get-the-list-of-transactions-of-input-outputs-for-a-bitcoin-address-in-js">How to get the list of transactions of input/outputs for a bitcoin address in JSON format?</a></p>

<p>--</p>

<p>I'm not 100% sure what you're asking for but I hope what I provide helps you.</p>

CC BY-SA 3.0
2017-06-11T10:21:43.073Z
2017-06-17T19:03:53.697Z
2017-06-17T19:03:53.697Z
Marc Alexander
<p>That is really a waste of time. </p>

<p>Bitcoin and all other Altcoins which use the blockchain technology are used as the transaction ledger. So Just get/install your crypto ledger, update your ledger of your Bitcoin(altcoin).</p>

<p>When you need to know about particular transaction related to the address just use the pre-built tools to scan ledger.</p>

<pre><code>echo $bitcoin-&gt;gettransaction($trans_id);
</code></pre>

<p>just shown as above. </p>

<p>There is no need to log each transaction in database, because it is already logged in ledger. so if you want to moniotor some addresses, just create a cronjobs to monitor any transaction and send alert to the user.</p>

CC BY-SA 3.0
2017-06-11T13:55:30.637Z
that gets a transaction of a tid. how would you know when an address receives an incoming or it going transaction?
Patoshi パトシ
CC BY-SA 3.0
2017-06-11T19:04:04.693Z
That has to be done using cron jobs to monitor the blockchain scanning third party server(https://blockchain.info) or local wallet installation.
Jitendra
CC BY-SA 3.0
2017-06-12T04:21:20.423Z
That's the thing, do you use a cron job to monitor the address or you monitor every block and see if there is the monitored address in each block?
Patoshi パトシ
CC BY-SA 3.0
2017-06-12T17:59:19.540Z
There are Trillions of possible public key, so it is not viable solution to monitor each and every key. But it is usable if we have a defined limited set of public key from some user.
we can use this cronjobs to allow to track Five or Six public key per user for thousand of users without any overhead on Server.
Jitendra
CC BY-SA 3.0
2017-06-12T18:03:23.370Z
yes i have a list of btc pub keys that i want to monitor.
Patoshi パトシ
CC BY-SA 3.0
2017-06-12T18:33:20.560Z
congrats!!, in that case you can use cronjobs easily to monitor them.
Jitendra
CC BY-SA 3.0
2017-06-12T20:04:18.360Z
Use importaddress in Bitcoin Core to mark the addresses you're interested in as watch-only addresses, and then use default notification services (ZMQ or -walletnotify) to notify you when a new transaction affecting those addresses is seen on the network.
Pieter Wuille
CC BY-SA 3.0
2017-06-13T17:12:45.843Z
As PHP is mentioned in the question,I think @duckx want to make similar service like ZMQ or -walletnotify so I did not stated that earlier.
Jitendra
CC BY-SA 3.0
2017-06-18T19:20:08.923Z
i think -walletnotify solves the problem. but is there an alternative to not using bitcoin core as I don't want to download 200gb of the blockchain. what other bitcoin wallet app supports -walletnotify flag?
Patoshi パトシ
CC BY-SA 3.0
2017-06-11T10:34:35.440Z
2017-06-11T10:34:35.440Z
Jitendra
<p>I'm looking to build a blockchain address monitoring service for bitcoin and other altcoins. What is the best way to monitor a bunch of addresses for incoming/outgoing transactions? </p>

<p>Currently I wrote a php script that checks the address every 5 minutes for any new activity and then store this data to a file and then another 5 minutes I fetch the data again and diff the file to see any differences and if so do <strong>something</strong>. </p>

<p>Another method I was thinking was to fetch each block as its mined then see if any of the addresses match what I have listed then <strong>do something</strong>. </p>

CC BY-SA 3.0
2017-06-12T21:31:34.737Z
This is the solution: https://bitcoin.stackexchange.com/questions/24457/how-do-i-use-walletnotify
Patoshi パトシ
<blockchain><address><altcoin>
Building an blockchain address monitoring service. Best way to monitor an address for bitcoin and other altcoins?
Patoshi パトシ
# Building an blockchain address monitoring service. Best way to monitor an address for bitcoin and other altcoins?

(Asked by: username_0 on 2017-06-08)

I'm looking to build a blockchain address monitoring service for bitcoin and other altcoins. What is the best way to monitor a bunch of addresses for incoming/outgoing transactions?

Currently I wrote a php script that checks the address every 5 minutes for any new activity and then store this data to a file and then another 5 minutes I fetch the data again and diff the file to see any differences and if so do **something**.

Another method I was thinking was to fetch each block as its mined then see if any of the addresses match what I have listed then **do something**.

**Tags:** blockchain, address, altcoin

> **Comments:**
> **username_0**: This is the solution: https://bitcoin.stackexchange.com/questions/24457/how-do-i-use-walletnotify  

---

## 2 answers

### Answer by username_1 on 2017-06-11. Score: 1 | Accepted answer

Since you mentioned PHP you can install a Bitcoin Node on your server and then use EasyBitcoin-PHP: <https://github.com/aceat64/EasyBitcoin-PHP>

Then use the Bitcoin API:
<https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list>

To list all transactions associated with an account:

```
echo $bitcoin->getreceivedbyaddress($btc_address);

```

"Returns the amount received by in transactions with at least [minconf] confirmations. It correctly handles the case where someone has sent to the address in multiple transactions. Keep in mind that addresses are only ever used for receiving transactions. Works only for addresses in the local wallet, external addresses will always show 0."

So you could run this and compare with your DB to see if a new transaction appears that isn't already in the DB.

--

To monitor a balance of an account you can just check on each page load (and update your DB if you wanted to):

```
echo $bitcoin->getbalance($user['id'], 1);

```

Get one of your users addresses:

```
echo $bitcoin->getaccount($user['id']);

```

To check transactions:

```
echo $bitcoin->gettransaction($trans_id);

```

--

You could also use an API:
[How to get the list of transactions of input/outputs for a bitcoin address in JSON format?](https://bitcoin.stackexchange.com/questions/51794/how-to-get-the-list-of-transactions-of-input-outputs-for-a-bitcoin-address-in-js)

--

I'm not 100% sure what you're asking for but I hope what I provide helps you.


---

### Answer by username_2 on 2017-06-11. Score: 0

That is really a waste of time.

Bitcoin and all other Altcoins which use the blockchain technology are used as the transaction ledger. So Just get/install your crypto ledger, update your ledger of your Bitcoin(altcoin).

When you need to know about particular transaction related to the address just use the pre-built tools to scan ledger.

```
echo $bitcoin->gettransaction($trans_id);

```

just shown as above.

There is no need to log each transaction in database, because it is already logged in ledger. so if you want to moniotor some addresses, just create a cronjobs to monitor any transaction and send alert to the user.

> **Comments:**
> **username_0**: that gets a transaction of a tid. how would you know when an address receives an incoming or it going transaction?  
> **username_2**: That has to be done using cron jobs to monitor the blockchain scanning third party server(https://blockchain.info) or local wallet installation.  
> **username_0**: That's the thing, do you use a cron job to monitor the address or you monitor every block and see if there is the monitored address in each block?  
> **username_2**: There are Trillions of possible public key, so it is not viable solution to monitor each and every key. But it is usable if we have a defined limited set of public key from some user. we can use this cronjobs to allow to track Five or Six public key per user for thousand of users without any overhead on Server.  
> **username_0**: yes i have a list of btc pub keys that i want to monitor.  
> **username_2**: congrats!!, in that case you can use cronjobs easily to monitor them.  
> **username_3**: Use importaddress in Bitcoin Core to mark the addresses you're interested in as watch-only addresses, and then use default notification services (ZMQ or -walletnotify) to notify you when a new transaction affecting those addresses is seen on the network.  
> **username_2**: As PHP is mentioned in the question,I think @duckx want to make similar service like ZMQ or -walletnotify so I did not stated that earlier.  
> **username_0**: i think -walletnotify solves the problem. but is there an alternative to not using bitcoin core as I don't want to download 200gb of the blockchain. what other bitcoin wallet app supports -walletnotify flag?  

---

