Categories
Uncategorized

5 minutes to Install Hyperledger Explorer with Fabric v2.0.0 on Ubuntu 18.04 DigitalOcean (Unofficial)

I am sharing this as an unofficial guide as Hyperledger Explorer hasn’t been officially confirmed as Fabric v2.0.0 ready. But it seems to work fine, so let’s play with it and give feedback to the project accordingly.

Hyperledger Explorer is a browser that can be used to view the activities on a block chain network. The following guide installs Hyperledger Explorer on a basic Ubuntu 18.04 DigitalOcean droplet and it is built upon the sample network of Hyperledger Fabric 2.0.0.

点击这里即可查看本文的中文版。

Depending on the speed of the network connection,you can just about run all the steps below perfectly and install it in 5 mins. Let’s start. (I recommend getting at least the $10 bucks a month Droplet from DigitalOcean, you will need the 2GB RAM to run it smoothly, use my link (Discount code for newbies, I get some free referral credits too) to sign up. Then run the following steps.

Check out my other articles on just running Hyperledger Fabric 2.0.0 and Hyperledger Composer. We aim to publish a full set of these guides on how to play around with Hyperledger technologies. Chinese version of these articles will be available via Jasmine Yang soon. Eugene Yong tested every line of code in this article.

For new droplets, set the locale (choose en_US.UTF-8 if in doubt) and do apt update/upgrade.

sudo dpkg-reconfigure locales
sudo apt-get update && sudo apt-get upgrade

There will be errors if you try to install Hyperledger Explorer as a root, therefore, for the rest of the set-up, you will be using the new user “dora” to do it. You will be prompted to set up a new password for the user which you will be using later. You will also need to give “dora” the sudo access by setting the permission. ( Eugene Yong picked the name.)

sudo adduser dora
sudo usermod -aG sudo dora
#Switch to the newly created user
su - dora

In order to run Hyperledger Explorer, you will need the following prerequisites:
– Nodejs version 8: 8.9.4 or greater _or_ version 10: 10.15.3 or greater
– PostgreSQL 9.5 and above
– jq

In order to set up Hyperledger Fabric 2.0.0, you will need the following:
– cURL
– Git
– Docker version 17.06.2-ce or greater.
– Docker Compose version 1.14.0 or greater.
– Go version 1.13.x is required.
– Nodejs version 8: 8.9.4 or greater _or_ version 10: 10.15.3 or greater
– npm version 5.6.0 or greater.
– Python

sudo apt-get install curl git docker.io docker-compose nodejs npm python
#Updating npm to 5.6.0
sudo npm install npm@5.6.0 -g
#Setting up docker configuration
sudo usermod -a -G docker $USER
sudo systemctl start docker
sudo systemctl enable docker
#Installing golang
wget https://dl.google.com/go/go1.13.6.linux-amd64.tar.gz
tar -xzvf go1.13.6.linux-amd64.tar.gz
sudo mv go/ /usr/local
#edit gopath in .bashrc
pico ~/.bashrc
#(add these 2 lines to end of file)
export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin
#Install postgres & jq for Explorer
sudo apt-get install jq postgresql postgresql-contrib
service postgresql restart
#Log out and log back in as dora
exit
su - dora

After installing the dependencies, you can now set up Hyperledger Fabric 2.0.0.

curl -sSL https://bit.ly/2ysbOFE | bash -s 2.0.0
cd ~/fabric-samples/test-network
./network.sh up createChannel
./network.sh deployCC

You will see `========= Channel successfully joined ===========` when the first script is done. You will see a list of cars printed in your logs when the script is deployed.

Now, setup Explorer

cd
git clone https://github.com/hyperledger/blockchain-explorer.git
#Setup DB
cd blockchain-explorer/app/persistence/fabric/postgreSQL
chmod -R 775 db/
cd db
./createdb.sh

You can use the following command to ensure that your PostgreSQL up and running

pg_lsclusters

Setup the first-network.json path to point at the right folder. Use the sample below if you follow every steps in the guide so far.

Configure Hyperledger Explorer based on the setup of the fabric. In the first-network.json, change the fabric-path to where your fabric-samples folder is found. Also, change the adminPrivateKey of “Org1MSP” to the correct path.

ls ~/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/

Note down the filename and use it to set the right parh below.

cd ~/blockchain-explorer/app/platform/fabric/connection-profile
nano first-network.json

Now modify “/ca4d946a621c0f528af9a3a6d05083d16afa7763da38b7e6c8d48c346b1d3034_sk” to the correct path. Please check all 3 paths in the file.

{
"name": "first-network",
"version": "1.0.0",
"license": "Apache-2.0",
"client": {
"tlsEnable": true,
"adminUser": "admin",
"adminPassword": "adminpw",
"enableAuthentication": false,
"organization": "Org1",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"fullpath": true,
"adminPrivateKey": {
"path": "/home/dora/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk"
},
"signedCert": {
"path": "/home/dora/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem"
}
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/home/dora/fabric-samples/test-network/organizations/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"
}
}
}
}

There is a script found in the blockchain-explorer folder that does this for you. You can also use the ./main.sh script to remove the dependencies (./main.sh clean) or run test for the explorer setup (./main.sh test).

cd blockchain-explorer
./main.sh install
./start.sh

Your Hyperledger Explorer should be properly set up and you can access it at http://<Your-IP-Address>:8080. If it prompts you to log in, use admin:adminpw.

You can check blockchain-explorer/logs/console/console-date.log to see if Hyperledger Explorer is running properly.

Reminder: Check out my other articles on just running Hyperledger Fabric 2.0.0 and Hyperledger Composer. We aim to publish a full set of these guides on how to play around with Hyperledger technologies. Chinese version of these articles will be available via Jasmine Yang soon. Eugene Yong tested every line of code in this article.

点击这里即可查看本文的中文版。

Leave a Reply

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