Integration with Mastercore Volume 2

Shannon Code here: During my AmA I was asked about monitoring an address so they could log incoming deposits into a database. I researched a bit, asked the core developers here on the development team and came up with a pretty elegant solution.

Continuing with the integration demonstration here: I’ll demonstrate how this can be done.

This example is of course a simplistic version, there is very little error handling and only the simplest “mvp” Minimum Viable Product has been demonstrated. I handled it this way to make things easier to follow along with.

Lets get started:

First off lets clone the example files so you can follow along:

> git clone

This should get you a copy of the files needed. I (being a .Net developer) am writing this app in node, but I’m using the visual studio node tools for VS2013, I have included the project files in the event that you would like to also use Visual Studio.

You will need to install the dependencies. npm is used to install the dependencies.

If using Visual Studio


If using bash

Modify your copy of config.js to reflect the information needed to connect to your Mastercore instance.

Start the application

> node server.js

or if in Visual Studio click the play button


You should now be able to access the application via your web-browser.

You can also check out my live version here:


Diving In

First things first, bitcoind has the walletnotify flag built right in, I’m illustrating how to harness this capability. I found a great resource via this post

Wallet notify works by telling bitcoind you want to execute some command locally whenever a wallet event happens. Incoming tx, confirmations, outgoing tx, etc.


walletnotify=~/.bitcoin/ %s

This excerpt is from my bitcoin conf file and simply says run and append any parameters. In this case it will be a transaction id.

My simply runs curl on my notify endpoint to persist the transaction

So looking back at the node app we can visit the /notify url to monitor transactions: You will notice an address we want to monitor. Sending any transactions to this address should now create records in our database.

Testing it out

Nothing in the database:


Make a deposit

Now we have a transaction id stored in our database!


How’d That happen?

I’ll dive into the node just a bit now to show how that works behind the scenes.

Here we now include the sqlite3 library


Here are our routes for handling the /notify view and the /notify/:txid/ endpoint

I hope this helps answer how to monitor an address using Mastercore.

Shannon Code
Mastercoin Developer Evangelist & Head of Security

Integration with Mastercore Volume 2