Setting up the environment on your local machine can be very time consuming and frustrate you when you never have done it before. A lot of my teammates facing the issue to download and configure the prerequisites of Hyperledger Fabric where I want to help the community with my knowledge.
The initial tool we must install is GIT with (Skip this step if you already installed XCode)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" brew install git
If CURL is missing, which shouldn’t on your mac then use this
brew install curl
The next package we will focus on is Docker. This is the most important package because each artifact on Hyperledger Fabric is running in a docker container. We will also use Homebrew for this installation.
brew install docker brew install docker-compose
For developing and deploying chaincode it is essential to have GO or NodeJS. In our example, we will deploy a NodeJs chaincode and therefore we need to use in terminal
brew install golang brew install node@10
To check if you did everything right please use the following commands. If one of the commands gives an error that the version couldn’t be found then go back and take the step again.
git --version curl --version docker –version node --version
If everything works fine and docker is up and running (you can see the symbol on to top right corner), we can start with downloading with the fabric samples and run our first network.
Setting up the fabric-samples for Hyperledger Fabric 2.0
The fabric-samples are the initial git project with all officially supported example networks and chaincode for you to start with Hyperledger Fabric. You can easily get it with the help of GIT. Download it to a folder of your choice before you start:
curl -sSL https://bit.ly/2ysbOFE | bash -s
It is important that you save the path to the Hyperledger Fabric binaries for further developments. Please be sure that you use the absolute path
For checking that you did it right use this
If it returns a version, then we are ready to go to set up the first network.
Demonstration of the test-network in Hyperledger Fabric 2.0
For setting up the environment we have to move to in the terminal to subfolder test-network and run the basic network with the belonging CouchDB.
./network.sh up createChannel -ca -s couchdb
Now, if everything was correct, we can deploy the smart contract. You can choose between the examples basic, ledger, private, sbe, and secured. We will go with the basic chaincode and use the NodeJs code example.
With Docker, we can verify that our network is up and running. If you want to take the network down just use ./network.sh down.
You see that there are two organizations running with each a peer, a CouchDB, a certification authority, a chaincode container, and a single orderer, who will be used by both organizations.
Hyperledger Fabric 2.0 offers a new and easy setup. In this article we set up the environment you need as a developer for doing further developments. If you have questions or feedback, then please leave a comment. I’m curious about if everything worked as described here or if you faced any issues.