The easiest way to go would obviously be to consume a ready-made API service such as blockchain.info’s Data API, however then we’d miss most of the fun, and so instead we’re going to set up a Bitcoin core full node, and consume its native JSON RPC API in a web front-end Blockchain Explorer application.
Ready? let’s do it!
Architecture and Technologies
System layout is pretty simple. Here are two possible configurations:
Blockchain Explorer – Layout Option 1

This is the simplest and easiest configuration to setup.
Blockchain Explorer – Layout Option 2

Another possibility (without using a reverse proxy) would be to configure the JSON RPC Proxy server machine’s IP address in bitcoin.conf file as follows
rpcallowip=[json-rpc-proxy-host-ip]
Running The Bitcoin Core Node
Whichever path you take, make sure to provide it with a volume with at least 170GB of free space, 2GB swap space and 1GB of RAM.
bitcoin.conf
server=1
disablewallet=1
rpcuser=
rpcpassword=
txindex=1
rpcallowip=127.0.0.1
bitcoin.conf should be located at the bitcoin core root data directory. This is the folder that will be used by bitcoin core to create and maintain its databases, indexes and the config file.
By default on Windows installations its location is %APPDATA%\Bitcoin, on Linux it is ~/.bitcoin/ and on Mac OS it is ~/Library/Application Support/Bitcoin/.
Notes
- server=1 property tells the node to run the JSON RPC service and accept connection requests (by default for mainnet on port 8332)
- txindex=1 tells the node to maintain a transactions index. Without it, the node will not index transactions (only blocks) so we won’t be able to run RPC queries to get raw transaction details. If you forget to set this flag before running the node and then want to enable it, then you’ll first need to run the node with the -reindex command line argument to construct the transactions index.
- disablewallet=1 tells the node not to provide any wallet management functionality, as we’re only interested in querying the blockchain data for the sake of this exercise.
- rpcallowip=127.0.0.1 tells the node to accept incoming connections on the local interface. If you plan to install the proxy on a different machine than the bitcoin core node, you’ll need to either set the ip address to your proxy’s machine address, or add more rpcallowip entries (you can add as many as you need), or install a local reverse proxy to tunnel requests from all interfaces to the local 127.0.0.1 interface.
The JSON RPC Proxy Server
Its purpose is to accept AJAX calls from the frontend application over its REST API, format the requests according to the JSON RPC protocol, relay them to the bitcoin core node and send the response back to the frontend. It currently exposes the following REST endpoints:
REST Endpoints
- GET /api/health
- POST /api/connect
- GET /api/disconnect
- GET /api/get-block-count
- GET /api/get-blockchain-info
- GET /api/get-block/:blockhash
- GET /api/get-raw-transaction/:txid
The connect route is used to establish a connection with the bitcoin JSON RPC Proxy server. This method has to be called first before we can make any further queries. The frontend calls this method when we click the “Connect” button.
JSON RPC Methods
- /api/get-blockchain-info route executes the getblockchaininfo JSON RPC method call
- /api/get-block route executes the getblock JSON RPC method call and returns the results in JSON format
- /api/get-raw-transaction route executes the getrawtransaction JSON RPC method call and returns the results in JSON format
- /api/get-block-count route (currently unused by the frontend application) executes the getblockcount JSON RPC method call.
Installing & Running the Proxy Server
- Clone the project
- Go into the project folder: cd bitcoin-json-rpc-proxy
- Install dependencies and compile: npm install
- Run the proxy server: npm start
- That’s it!
The Web Frontend Application
This version is modest and currently provides the ability to view basic blockchain information, search for blocks and traverse them by paging to the next/previous block, and drill down into individual transactions.
To start the exploration the user needs to login by providing the full node details: host, port, rpc username and password.
Installing & Running the Frontend
- Clone the project
- Go into the project folder: cd blockchain-explorer
- Install dependencies: npm install
- Install Angular CLI globally: npm install -g @angular/cli
- Run the frontend (will automatically spawn the browser): npm start
- That’s it!
To Be Continued…
- Add a blockchain indexer to the mix so we can further search for and check any public (wallet) address (look at all its related transactions, calculate its current balance based on the unspent transaction outputs etc.)
- Find block by block number (height)
- Decypher secret messages cleverly hidden within the blockchain data
- Fiddle with cryptographic functions
- Sign and verify messages
- more…
Zacky
Leave A Comment