Blockchain Explorer Integration with Hyperledger Fabric

Pavan Adhav
Coinmonks
4 min readFeb 12, 2020

--

Here I am assuming that you have already Hyperledger fabric network up and running. Make sure that all necessary container services working fine and you are able to invoke/query transactions. In my case. I have the following configuration of the network.

Hyperledger Explorer:

Hyperledger Explorer is a simple, powerful, easy-to-use, well maintained, open-source utility to browse activity on the underlying blockchain network.

Please make sure that you have installed the appropriate version of the explorer, node, and fabric should be matching as below.

Discover and review best Blockchain softwares

Clone the explorer from HERE. Once cloned, the repo will have below the structure.

Explorer used PostgreSQL for storing data after fetching from a peer. Install the following dependencies.

  • Nodejs 8.11.x (Note that v9.x is not yet supported)
  • PostgreSQL 9.5 or greater
  • jq

Step1:

Go to blockchain-explorer/app and modify the explorerconfig.json to update PostgreSQL database settings. I

If you have added different username and configuration for database, make sure to update in this file (explorerconfig.json).

Go to cd cd blockchain-explorer/app/persistence/fabric/postgreSQL/db , If you are not able to see db folder or anything inside db folder, change the permission. chmod -R 775 db/

Run sudo -u postgres ./createdb.sh , you will be able to see the creating of the database and the necessary tables for storing data.

STEP 2:

Fabric Network Configuration

Once Fabric network is up and running, go to /blockchain-explorer/app/platform/fabric/config.json in Explorer repo. Under the first network add profile path.

Defining test.json (configuration File): Defind a test.json file under connection profile folder.

Add appropriate configuration file, key, cert, URL. Make sure that all files and certificates are available at a specific path. Make necessary changes as per your configuration. We are fetching all data from one peer.

Follow the below steps for building explorer.

  • cd blockchain-explorer
  • npm install
  • cd blockchain-explorer/app/test (required if you want to execute test as well)
  • npm install (required if you want to execute test as well)
  • npm run test (required if you want to execute test as well)
  • cd client/
  • npm install

STEP 3:

Go to the new terminal cd blockchain-explorer/ and run the first command
1) ./start.sh for starting server
2) ./stop.sh for stopping server

Once the server started successfully, go to localhost:8080 on the browser, you need to log in and once logged in successfully, you will be able to see a screen like below.

There could be a difference in the number of blocks and transaction, it would show your network transactions.

Youtube

For more details, you could follow my youtube video series about how to integrate Blockchain Explorer with Hyperledger Fabric.

Video 1:

Video 2:

Video 3:

Most importantly, you can see all log under cd blockchain-explorer/logs/console/console.log.

Server fetches data continuously from the peer, all the logs will get printed inside the console file. for reference find the below console.log file.

Configuration of logging

By using the following environment variables, you can control the log level of each component (app, db, and console). You can set these ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF string to each level. Each file is rolled by both date (7days) and size (8MB).

LOG_LEVEL_APP

  • Log level regarding the application layer. The logs are written to logs/app/app.log.

LOG_LEVEL_DB

  • Log level regarding the backend layer. The logs are written to logs/db/db.log.

LOG_LEVEL_CONSOLE

  • Log level regarding the console. The logs are written to logs/console/console.log.

LOG_CONSOLE_STDOUT

  • You can switch the destination of the console log from file to standard output.

For stopping server run ./stop.sh on the home directory of the repo. Once the application is up and running, you can play around it. For more details please go through the youtube video mentioned above. In case if you are facing any difficulty while integrating Explorer with fabric, you can reach me.

Thank you.

Get Best Software Deals Directly In Your Inbox

--

--