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 - Blocks Details
Provides details related to a list of blocks and block information (by clicking on each block hash in the list) - Peer List
Provides details on peer nodes for each participant organization - Chaincode List
Provides detail on chaincodes deployed - Transaction details
Provides details on ongoing transactions in form of transactions per second
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.
- Setup NodeJS (nodejs 6.9.x)
- Setup MySQL database (MySQL 5.7 or greater)
- Following needs to be installed for having Hyperledger explorer manage the Hyperledger Fabric blockchain network (channels)
- docker 17.06.2-ce [https://www.docker.com/community-edition]
- docker-compose 1.14.0 [https://docs.docker.com/compose/]
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.
- 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
- Hyperledger Explorer
- Hyperledger Explorer on Github
- Visualizing blockchain operations with Hyperledger explorer
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.
- Agentic Reasoning Design Patterns in AI: Examples - October 18, 2024
- LLMs for Adaptive Learning & Personalized Education - October 8, 2024
- Sparse Mixture of Experts (MoE) Models: Examples - October 6, 2024
thanks for this! but seems now the prerequisite is Postgres over Mysql
How to configure multiple channels in config.json file?