Hyperledger Explorer quick start

Screenshots and Installation steps for the Hyperledger Fabric network explorer.

Ben Longstaff
Feb 14, 2019 · 5 min read

The purpose of this article is so provide the minimum steps to get the simplest configuration of Hyperledger Explorer up and running on a Mac to show the state of a Hyperledger Fabric network.

This article is has the following structure

  • Screenshots of the end result.
  • Dependency installs
  • Installing Hyperledger Explorer

Hyperledger Explorer is an open source project that is intended to eventually support all of the Hyperledger distributed ledgers, currently it only supports Hyperledger Fabric.

Installing Dependancies

This article is written using Hyperledger Explorer release-3.9 and Hyperledger Fabric release 1.4.

Homebrew

If you don’t already have it installed follow the instructions on the site.

node.js (8.11.x)

Note that v9.x is not currently supported.

$ which node
/usr/local/bin/node
$ npm install -g n$ sudo n 8.11.1$ node --version
v8.11.1

PostgreSQL

$ brew install postgres$ which postgres
/usr/local/bin/postgres
$ postgres --version
postgres (PostgreSQL) 11.1

jq

$ brew install jq$ which jq
/usr/local/bin/jq
$ jq --version
jq-1.6

Docker

$ which docker
/usr/local/bin/docker
$ docker --version
Docker version 18.09.1, build 4c52b90
$ which docker-compose
/usr/local/bin/docker-compose
$ docker-compose --version
docker-compose version 1.23.2, build 1110ad01

Hyperledger Fabric

All of the terminal commands assume that the Hyperledger Fabric samples are installed at /tmp

$ cd /tmp/fabric-samples/first-network/
$ ./byfn.sh generate
$ ./byfn.sh up

Install Hyperledger Explorer

To keep things as simple as possible all of the default values from the Hyperledger tutorials are used.

I ran into some issues where things silently failed so I have included screenshots for some of the install steps as a reference to what it should look like.

For the purpose of adding commands into this doc I am cloning the repo into ~/Hyperledger

$ git clone https://github.com/hyperledger/blockchain-explorer.git

For the purpose of the demo all of the default database settings will be left as is

Database

Using the default configuration at

~/Hyperledger/blockchain-explorer/app/explorerconfig.json

Start the PostgreSQL.

$ pg_ctl -D /usr/local/var/postgres start

To create the database

$ cd ~/Hyperledger/blockchain-explorer/app/persistence/fabric/postgreSQL/db$ ./createdb.sh

App Config

I have updated the app config below to include the settings required to use fabric-ca as the certificate authority.

$ vim ~/Hyperledger/blockchain-explorer/app/platform/fabric/config.json

The updated config should look like

{
"network-configs": {
"network-1": {
"version": "1.0",
"clients": {
"client-1": {
"tlsEnable": true,
"organization": "Org1MSP",
"channel": "mychannel",
"credentialStore": {
"path": "./tmp/credentialStore_Org1/credential",
"cryptoStore": {
"path": "./tmp/credentialStore_Org1/crypto"
}
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"certificateAuthorities": "fabric-ca",
"mspid": "Org1MSP",
"fullpath": false,
"adminPrivateKey": {
"path": "/tmp/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore"
},
"signedCert": {
"path": "/tmp/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts"
}
},
"Org2MSP": {
"certificateAuthorities": "fabric-ca",
"mspid": "Org2MSP",
"adminPrivateKey": {
"path": "/tmp/fabric-samples/first-network/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore"
}
},
"OrdererMSP": {
"mspid": "OrdererMSP",
"adminPrivateKey": {
"path": "/tmp/fabric-samples/first-network/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/tmp/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://localhost:7051",
"eventUrl": "grpcs://localhost:7053",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
},
"peer1.org1.example.com": {
"url": "grpcs://localhost:8051"
},
"peer0.org2.example.com": {
"url": "grpcs://localhost:9051"
},
"peer1.org2.example.com": {
"url": "grpcs://localhost:10051"
}
},
"orderers": {
"orderer.example.com": {
"url": "grpcs://localhost:7050"
}
},
"certificateAuthorities": {
"fabric-ca": {
"url": "http://localhost:7054",
"httpOptions":{
"verify": false
},
"registrar": {
"enrollId": "admin",
"enrollSecret": "adminpw"
},
"caName": "fabric-ca"
}
}
},
"network-2": {}
},
"configtxgenToolPath": "/tmp/fabric-samples/bin",
"license": "Apache-2.0"
}

Build the App

$ cd ~/Hyperledger/blockchain-explorer
$ npm install

Initially I ran into an error here

$ npm install

> pkcs11js@1.0.16 install /Users/benlongstaff/Hyperledger/blockchain-explorer/node_modules/pkcs11js
> node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
.....npm ERR! errno 1
npm ERR! pkcs11js@1.0.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pkcs11js@1.0.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

the issue was caused by

$ xcodebuild -version
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

to fix it

$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

which then gave

$ xcodebuild -version
Xcode 10.1
Build version 10B61

run the app tests

$ cd ~/Hyperledger/blockchain-explorer/app/test
$ npm install
$ npm run test

build the client

$ cd ~/Hyperledger/blockchain-explorer/client
$ npm install
$ npm test -- -u --coverage
$ npm run build
$ serve -s build

start the backend

$ cd ~/Hyperledger/blockchain-explorer
$ ./start.sh

If everything has gone to plan you should now be able to access it at http://localhost:8080

Shutdown

$ cd ~/Hyperledger/blockchain-explorer/
$ ./stop.sh
$ cd /tmp/fabric-samples/first-network/
$ ./byfn.sh down

Next Steps

If you want to learn more about the architecture of Hyperledger Fabric checkout this cheatsheet I put together.

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Ben Longstaff

Written by

Playing at the intersection of privacy and personalisation. Fascinated by the state of trust in a world with leaky data.

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

More From Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade