Install Hyperledger Fabric V2.2 & Run Test Network 🚀

Errors covered | with each step snapshot | bring up HF network fast

Mohit Rakhade
Coinmonks
Published in
5 min readDec 7, 2020

--

Before starting this article, let me give you some context about it. In this article we will install Hyperledger Fabric and run test-network with clean and minimal steps, we will also look into possible errors that might lead you to scratch your head for hours if you don’t read this.

This article will hold your hand from zero to bring up network, If you want to intensify each term, I will highly recommend you to read KC Tam’s 👉 ( this ) article after completing this one, to understand how exactly things work in detail.

Before installing fabric samples make sure you have installed all the prerequisites

Quick Note: Refer my Golang artical to set golang environment 👇

To first install the fabric-sample run this command to install :

Fabric v2.3.0 is released but we will go with v2.2.0 ( as it is stable) and 1.4.9 is fabric CA version

This curl script will clone fabric-samples repo and pull Hyperledger Fabric binaries.

pulling binary images

It will only pull the images that did not exist and will use prev images ( if you have used fabric before )

If script successfully run then it will show all the images that you pulled, and will look like this —

Now, navigate to test-network to check its properly installed or not and we will do some operation ( init, invoke ) on test-network.

To start nice & fresh, run this command to tear down artifacts, crypto material, containers and chaincode images from previous runs to avoid unwanted error.

Now we are ready to bring our network up by running—

test-networks has two members i.e. Org1 & Org2. Each Org has two peers and One Orderer maintain the ordering service. We will able to see two peers and one orderer if we run —

Now we will create channel between Org1 and Org2, peer will also join the same channel ( default channel name : mychannel ), if we run —

You will find follwing message, if it’s successful

Lets deploy our chaincode, the script will install the chaincode dependencies if you are deploying it for first time —

🐞 It will fail if you do not set your GOROOT path and will say somthing like this —

ERR: GOROOT

Lets resolve this my setting GOROOT path ( do this only if you faced above ERR )

setting GOROOT path

Refer this, If you still facing errors 💁

&

To initialize the ledger run in your terminal—

result will look like this, if command is successful —

List the ledger by running this query —

if successful, output will look like this —

Command to change the owner by invoking asset-transfer chaincode —

respones if its successful—

query the asset-transfer (basic) chaincode running on peer0.org2.example.com

Result showing asset6 transferred to Chirstoper —

If you made it to the end, then you have installed HF, run test-network, and also perform some operation on chaincode.

Now to tear down the test network, run —

Congratulations 🤜🤛 you installed the fabric-samples and tested first network

Thank You for reading 🍃

Also, Read

Get Best Software Deals Directly In Your Inbox

--

--

Mohit Rakhade
Coinmonks

Diving deep into Decentralized world of Blockchian to achieve transparency, enhanced security, Increased Efficiency & Improved Traceability ✨