How to Install Hyperledger Explorer & Access Fabric Network

Hyperledgder Explorer is a Blockchain explorer which can be used to view the details on the one or more blockchain network (channels) created using Hyperledger Fabric 1.0.

In this post, you will learn about some of the following:

  • Introduction to Hyperledger Explorer App
  • Installation/Setup of Hyperledger Explorer
  • Configure hyperledger explorer for the first network
  • Starting the Explorer App

Introduction to Hyperledger Explorer App

Hyperledger Explorer is a Nodejs based web app which runs on Node/ExpressJS with MySQL as the backend database. It provides details related Fabric blockchain network (channels) based on configuration provided in the file, blockchain_explorer/config.json. The following represents some of the key details provided by the explorer app vis-a-vis the data it captures for the Hyperledger Fabric blockchain (channels).

  • Summary information
    Provide details related to a channel including number of peers, blocks, transactions, chaincode

    Hyperledger Explorer Summary Dashboard

    Figure 1. Hyperledger Explorer Summary Dashboard

  • Blocks Details
    Provides details related to a list of blocks and block information (by clicking on each block hash in the list)

    Hyperledger Explorer Blocks Information

    Figure 2. Hyperledger Explorer Blocks Information

  • Peer List
    Provides details on peer nodes for each participant organization

    Hyperledger Explorer - List of Peer Nodes

    Figure 3. Hyperledger Explorer – List of Peer Nodes

  • Chaincode List
    Provides detail on chaincodes deployed

    Hyperledger Explorer List of Chaincodes

    Figure 4. Hyperledger Explorer – List of Chaincodes

  • Transaction details
    Provides details on ongoing transactions in form of transactions per second

    Hyperledger Explorer Transaction Details

    Figure 5. Hyperledger Explorer – Transaction Details

The details on package used can be found in package.json file in the root folder, blockchain-explorer (blockchain_explorer/package.json). The app files can be found in the folder, explorer_client (blockchain_explorer/explorer_client).


Installation/Setup of Hyperledger Explorer

The following needs to be installed/setup before setting up the explorer.

Once done with above, set up the Hyperledger Explorer using the following instructions:

  • Clone Explorer GitHub repository
    git clone https://github.com/hyperledger/blockchain-explorer.git
    cd blockchain-explorer
    
  • Create/setup explorer database by executing following command. The command executes the script, blockchain_explorer/db/fabricexplorer.sql
    mysql -u<username> -p < db/fabricexplorer.sql
    

Installation/setup details can also be found on this GitHub page, Setting up Hyperledger Explorer.

Configure Hyperledger Explorer for First Network

The Hyperledger explorer comes bundled with the files related to building your first network (BYFN) which can be found in the folder, blockchain_explorer/first_network. You could configure config.json file appropriately to either refer the Fabric network built with bundled folder or BYFN installed as part of fabric_samples. I had the BYFN installed as part of fabric samples. Thus, I configured the config.json with appropriate path referring to already existing byfn network (created using byfn.sh).

Here is the sample config.json file:

{
    "network-config": { 
        "org1": {
            "name": "peerOrg1",
            "mspid": "Org1MSP",
            "peer1": {
                "requests": "grpcs://127.0.0.1:7051",
                "events": "grpcs://127.0.0.1:7053",
                "server-hostname": "peer0.org1.example.com",
                "tls_cacerts": "../fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
            },          
            "peer2": {
                "requests": "grpcs://127.0.0.1:8051",
                "events": "grpcs://127.0.0.1:8053",
                "server-hostname": "peer1.org1.example.com",
                "tls_cacerts": "../fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
            },          
            "admin": {
                "key": "../fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore",
                "cert": "../fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts"
            }
        },      
        "org2": {
            "name": "peerOrg2",
            "mspid": "Org2MSP",
            "peer1": {
                "requests": "grpcs://127.0.0.1:9051",
                "events": "grpcs://127.0.0.1:9053",
                "server-hostname": "peer0.org2.example.com",
                "tls_cacerts": "../fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
            },          
            "peer2": {
                "requests": "grpcs://127.0.0.1:10051",
                "events": "grpcs://127.0.0.1:10053",
                "server-hostname": "peer1.org2.example.com",
                "tls_cacerts": "../fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt"
            },          
            "admin": {
                "key": "../fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore",
                "cert": "../fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts"
            }
        }       
    },
   "host":"localhost",
   "port":"8080",
   "channel": "mychannel",
   "GOPATH":"../artifacts",
   "keyValueStore":"/tmp/fabric-client-kvs",
   "eventWaitTime":"30000",     
   "mysql":{
      "host":"127.0.0.1",
      "port":"3306",
      "database":"fabricexplorer",
      "username":"root",
      "passwd":"root"
   }
}

Make a note of some of the following:

  • Explorer starts with host URL as localhost and port as 8080.
  • The database information including the database name, username and passwd needs to be passed correctly.
  • The name of organizations, Org1MSP and Org2MSP can be found in fabric-samples/first-network/configtx.yaml file.
  • The port on which the peer nodes accept requests can be found by executing the docker ps command. The following screenshot represents the same. Make a note that it is important to provide the correct URL including port information for each peer node.

    Figure 6. Hyperledger Explorer Peer Nodes URLs with Port Info

    Figure 6. Hyperledger Explorer Peer Nodes URLs with port information

  • The part for certificates including admin certificates should be correct.



Starting the Explorer App

  • Start your first network (channel such as mychannel) using the command such as following:
    fabric-samples/first-network/byfn.sh -m up
    
  • If the configuration is provided correctly (in config.json file), one can successfully start the app by executing the command, ./start.sh. The log information (any error during the server startup) can be checked in the file, log.log.
  • Access the explorer at the URL such as http://localhost:8080.

Further Reading

Summary

In this post, you learned about some of the following:

  • Hyperledger blockchain explorer web app
  • Setting up Hyperledger explorer
  • Configuring explorer to work with Hyperledger Fabric
  • Accessing Fabric network (channel) created with byfn.sh from explorer browser

Did you find this article useful? Do you have any questions about this article or setting up/installing or configuring Hyperledger Explorer? Leave a comment and ask your questions and I shall do my best to address your queries.

Ajitesh Kumar
Follow me

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com
Posted in BlockChain, Hyperledger, Tools, Tutorials. Tagged with , , .

2 Responses

Leave a Reply

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