Hyperledger Explorer Setup with Hyperledger Fabric

3 min readDec 9, 2019

Hyperledger Explorer is a simple, powerful, easy-to-use, highly maintainable, open-source browser for viewing activity on the underlying blockchain network.

To execute Explorer you should have fabric-samples with first-network UP.

For Fabric Network following are the commands to run hyperledger first network

1.Install Docker &Docker Compose

sudo apt update
sudo apt upgrade
# Docker Installation
sudo apt-get remove docker docker-engine docker.io containerd runc
docker system prunedocker system prune -a

sudo apt update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.iosudo groupadd docker
sudo usermod -aG docker $USER
#exit from docker installation#docker-compose installsudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-compose

2.Install Fabric

curl -sSL https://bit.ly/2ysbOFE | bash -s
sudo nano ~/.profile
#add this in last to set the path of cryptogen it will be used when #we create our cryptoconfig or first network
export PATH=/home/ubuntu/fabric-samples/bin:$PATH
source ~/.profile

3. Run Fabric

cd /home/ubuntu/fabric-samples/first-network
./byfn.sh up
#If it runs correctly then its ok but if it does not run Correctly #then
#check it is running correctly or not
#if not delete all docker images
docker kill $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images peer* -q)
docker system prune
docker system prune -a

4. To run fabric explorer

#Install GO
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
tar -xzvf go1.11.2.linux-amd64.tar.gz
mv go/ /usr/local
nano ~/.bashrc
#add these two lines in bashrc to set paths of GO
export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin
source ~/.bashrc
#Clone blockchain explorer
git clone https://github.com/hyperledger/blockchain-explorer.git
#Install POSTGRE
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
#Configure blockchain explorer
cd blockchain-explorer/app
modify explorerconfig.json
#set your database username and password
cd blockchain-explorer/app/persistence/fabric/postgreSQL
chmod -R 775 db/
cd blockchain-explorer/app/persistence/fabric/postgreSQL/db
#If createdb.sh is not running then copy explrerpg.sql file into the postgres directory then run the cmds
$ sudo -u postgres -i
$ ALTER USER postgres PASSWORD 'password'
$ psql postgres -v dbname=fabricexplorer -v user=postgres -v passwd=password -f ./explorerpg.sql ;

5. set the connection profile in explorer:

$ cd /home/ubuntu/blockchain-explorer/app/platform/fabric/connection-profile/
$ nano first-network.json
# change the following PATH according to your need
# adminPrivateKey path
# signedCert path
# tlsCACertspath
$ SAMPLE: /home/ubuntu/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/aaacd899a6362a5c8cc1e6f86d13bfccc777375365bbda9c710bb7119993d71c_sk
#especially bold part

6. Now run the explorer.

$ cd blockchain-explorer
$ ./main.sh install
$ ./main.sh clean // if u get any error
$ ./main.sh test
$ cd blockchain-explorer/
$ ./start.sh (it will have the backend up). // if u will get error in channel then delete the channel manually from postgres.
$ ./start.sh debug (it will have the backend in debug mode).
$ ./start.sh print (it will print help).




DevOps/Cloud | 2x AWS Certified | 1x Terraform Certified | 1x CKAD Certified | Gitlab