Defining the block explorer endpoints 

In order for the block explorer to function correctly, we'll need to query the blockchain for addresses, block hashes, and transaction IDs so that we can search for a particular parameter and get that particular piece of data in return. Consequently, the first step that we'll need to carry out is to build a few more endpoints. To do this, lets proceed with the following steps: 

  1. Go to the dev/networkNode.js file and after the /consensus endpoint, let's define the first endpoint of our block explorer, /block/:blockHash, as follows: 
app.get('/block/:blockHash', function(req, res) { });

A specific blockHash will be sent with this endpoint, which, as a result, will simply return to us the block that the ...

Get Learn Blockchain Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.