How to explore Data inside of Blockchain Network in Javascript

In this tutorial, we’re gonna build API that allows us to explore the data inside of our Blockchain Network. We will have ability to search the entire Blockchain for a specific Block by Hash, for a specific Transaction by Id. We can also fetch data from our Blockchain Network for a specific User/Address.

Previous Post: How to build Consensus Algorithm for Blockchain Network in Javascript

Explore Data Endpoints

We will make 3 endpoints:

– GET /block/:hash: shows a specific Block by :hash.
– GET /transaction/:id: shows a specific Transaction by Transaction’s :id.
– GET /address/:address: shows all Transactions that an :address is related to (address/user is a sender or a recipient).

These endpoints use 3 Blockchain class finder methods:


Implement Blockchain class Finder Methods

Inside blockchain.js file, add 3 methods to Blockchain class:

Find specific Block by Hash

Find specific Transaction by Transaction’s Id

Find all Transactions by Address/User

Explore Data Endpoints

Inside api.js file, add 3 endpoints:

Block by Hash

Transaction by Id

Data related to Address/User

Run & Check results

– Run the API on Terminal with command:
npm run node1

– Broadcast some Transactions and mine on node1, then check with url http://localhost:3001/blockchain:

– Find Block by Hash:


– Find Transaction by Id:


– Find all Transactions by Address/User


Source Code


By grokonez | June 15, 2018.

Related Posts

1 thought on “How to explore Data inside of Blockchain Network in Javascript”

  1. Really wonderful tutorial! Very well documented and explained step wise as to how to go about the entire block chain and decentralised part

    However, I was wanting to know, how does one deploy such apps to be used on a global scale? Are the files distributed directly and the blockchain storage and all managed de-centrally, or use p2p? if so then how?
    Would like to hear your comments

Got Something To Say:

Your email address will not be published. Required fields are marked *