Blockchain has great documentation for PHP, but nothing really for node!

Does anyone here have any projects,where they used the blockchain.info Receive Payments API, in their node apps, to receive money / check for confirmations?

I learn a lot better by viewing / recreating example code so any you have would help me out tons!

2 Answers 2


I'm working on something like this now. I do not have a complete implementation built yet, so please bear with me for any errors or troubles that might arise. However, this might help get you on your feet...

I started by installing bitcoind and setting it up as a client which Node.js can interact with the Blockchain through. I did this by setting up bitcoin.conf with my Blockchain information and starting bitcoind in a screen. Take a look at this page for information on connecting bitcoind with your Blockchain account: https://blockchain.info/api/json_rpc_api

You'll also need middleware for Nodejs to interact with Blockchain through bitcoind. Here's the one Blockchain links to: https://github.com/jb55/node-bitcoin can be simply installed with:

npm install bitcoin

The readme file on this Git provides information and code snippits you can use to connect Nodejs with Blockchain. Node connects to your local bitcoin server:

var bitcoin = require('bitcoin'); var client = new bitcoin.Client('localhost', 8332, 'username', 'password');

Node gets the balance of all your addresses, with at least 6 confirmations:

client.getBalance('*', 6, function(err, balance) { if (err) return console.log(err); console.log('Balance:', balance); });

Here's a list of all the possible Blockchain API requests: en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list

You can use these functions to create and destroy wallet addresses, check their balances, as well as send funds from your script if you so desire.

Speaking briefly about security, double encryption is recommended and can be enabled in the Blockchain My Wallet 'Account Details' page. This means each address has it's own access password, on top of the master wallet password. Simple operations such as fetching a balance do not require both passwords to be sent, but sending funds would require Node to send both the master and wallet passwords. If you're using a server with a static IP, you can also use the 'IP Lock' setting in Blockchain to restrict access to outsiders. Gotcha: two-factor authorization must be disabled on your Blockchain wallet to allow access from your script.

  • Hey! Thanks this was actually really helpful! One question though! If I wanted to deploy my application to heroku how would this work? From my understanding this would only do everything locally right? Do I need to purchase a server to run the btcoind separately online then connect or?
    – gbachik
    Mar 12, 2014 at 19:15

I also found this node package that works very well for dealing with one Blockchain wallet at a time.


npm install blockchain-wallet

var BlockchainWallet = require('blockchain-wallet'),
blockchainWallet = new BlockchainWallet("YourGuid", "YourPassword"),
// Certain API methods require a second password if the wallet is second password protected, while others don't at all.
transactionBlockchainWallet = new BlockchainWallet("YourGuid", "YourPassword", "YourSecondPassword");

blockchainWallet.list(function(err, data) {
  if(err) {
   throw err;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.