Exploring Hyperledger Fabric and Hyperledger Explorer

Rahul Agarwal
4 min readMar 28, 2022

For permissioned blockchains, Hyperledger Fabric is one of the most prominent ones. Its backed by the Linux Foundation and open source, with good documentation so a good way to learn!

At its simplest, any number of nodes referred to as “peers” may form a private network (invite only) and all or a subset of them may participate in any number of “channels.” These channels are actually distinct blockchains so in the picture below we have Peer 3 participating in two blockchains with authorization for both Channel 1 and Channel 2. Other peers only have access to one channel. This allows for private data between a subset of peers. Unlike a public network all peers in this scheme need not have access to all data in the network.

Hyperledger Fabric network with two channels
Figure 1: Hyperledger Fabric network with two channels

Each peer is owned by an Organization (each organization may run more than one peer). The organization is essentially the owner and holds the necessary keys to access the network.

Since there are no miners someone else needs to perform similar functions of executing the smart contracts and achieving consensus. This is done by Endorsers and Orderers. The endorsers are peers that execute the contract and return their cryptographically signed endorsements. These endorsements are then collected by the Orderers to determine the correct order of transactions and create the next block. The block is then synchronized to every peer for that channel. There are a few other required components but not essential for this high-level discussion (reference docs).

Local Environment

The simple quick start sample provided creates a network with two organizations and one orderer with one channel.

Figure 2: Default test network

Follow the guide for the pre-requisites and then get the samples and docker images. At time of this writing its version 2.4. In whatever folder you want to work in, do the following:

curl -sSL https://bit.ly/2ysbOFE | bash -s

Once complete you will see a fabric-samples folder and if you do docker images you will a bunch of images it pulled.

Start the test network.

$ cd fabric-samples/test-network
$ ./network.sh up createChannel

Takes a few seconds and it should end with: Channel ‘mychannel’ joined. Now if you do a docker ps you will see the containers running for the 2 peers and 1 orderer.

Now to visualize what is going on in your personal test network, the Hyperledger Explorer is a nice project. Think of it like the public Etherscan to see what going on the Ethereum network. To run it follow the steps summarized here from the git readme.

//this is now in same folder as fabric-samples
$ mkdir hlf-explorer
$ cd hlf-explorer
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/config.json
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/examples/net1/connection-profile/test-network.json -P connection-profile
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/main/docker-compose.yaml

Copy over the organizations folder from where you started the network. This contains the necessary keys. Setup some variables and start.

$ cp -r ../fabric-samples/test-network/organizations .
$ export EXPLORER_CONFIG_FILE_PATH="./config.json"
$ export EXPLORER_PROFILE_DIR_PATH="./connection-profile"
$ export FABRIC_CRYPTO_PATH="./organizations"
$ docker-compose up -d

The first time, it must pull images so may take some time but otherwise it is quick. Do a docker ps and you will now see two additional containers for the explorer and its DB. Version 1.1.8 at time of this writing.

Containers for 2 peers, 1 orderer and Hyperledger Explorer
Figure 4: Containers for 2 peers, 1 orderer and Hyperledger Explorer

Point your browser to http://localhost:8080/ and login with the default exploreradmin/exploreradminpw and you can see your test network!

HLF Explorer Dashboard
Figure 4: HLF Explorer Dashboard


In the Hyperledger Explorer folder:

docker-compose down -v

In the fabric-samples/test-network folder

./network down

The next step is to do something useful and deploy some smart contracts known as chaincode in HLF that maybe the topic for my next post!

If these topics interest you then reach out to me and I will appreciate any feedback. If you would like to work on such problems you will generally find open roles as well! Please refer to LinkedIn.