Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Blockchain by (16.8k points)
edited by

I am using this bitcore npm package. https://bitcore.io/api/lib

And i want to monitor all the transactions over the blockchain, and read the input address, output address and amount associated with that transaction.

But I am unable to find the javascript method to invoke to accomplish this. Even i am not able to find a example for this.

I am looking for as short as something like

var someLib = require('some-bitcore-lib')

someLib.on('transaction-found', function(){

   // print everything

   console.log(arguments);

   // do something else;

})

Any help? Where can i find that some-bitcore-lib or how can i create that in nodejs?

1 Answer

0 votes
by (14.4k points)
edited by

In such cases, blockchain.info can come to your rescue. If you do not have your own node, use blockchain.info APIs by following the guidelines that are mentioned in https://github.com/blockchain/api-v1-client-node/tree/master/Socket

Use the code, 

const Socket = require('blockchain.info/Socket');

const mySocket = new Socket();

mySocket.onTransaction(function() 

 console.log(arguments);

});



However, you can keep a watch on your transactions by executing your own node and without depending on blockchain services like blockchain.info

How can you do that?

Assume that you are using Golang (btcd), you can view your transactions at http://godoc.org/github.com/btcsuite/btcrpcclient#Client.NotifyNewTransactions

You can even check out the Blockchain Certification Course by Intellipaat to have more knowledge about this topic.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...