Hyperledger Fabric is an exciting technology and is progressing rapidly with the approach of move fast and break things so it can sometimes turn out to be a soul-destroying task to set up the Fabric development environment. Even the official documentation falls short of discussing everything there is in setting up the environment. So, I have written this guide to lay down all the steps you will need to go through to set up the development environment. I will try to keep this guide updated to reflect the latest changes in the Fabric protocol.] I am not going to bore you with explaining what blockchain is and why it matters and explain the use cases of permissioned blockchain technology frameworks like Hyperledger Fabric. If you want to learn the basics of blockchain, Hyperledger Fabric, and its use cases. There is no better way than to study the official documentation here. Installing one wrong package version might generate errors that can take days to debug. These steps have been tested to work well on Ubuntu 18.04 LTS. Let us get started. cURL is a tool that is used to transfer data over the internet. Docker is a tool designed to make it easier to create, deploy, and run applications in virtual containers. We will use docker to set up simulate different peers in the network. We use docker CLI container to interact with the peers and ordering service, install and upgrade chaincode, and create and join channels. If you previously installed docker on your machine. You will need to remove all previous docker packages. You have now successfully removed Docker from the system completely. Run the command to run hello-world docker image. You need to eliminate the requirement of using sudo while working with docker Docker Compose is a tool for running multi-container Docker applications. You need to define all the containers that your application depends on in a .yaml file. Then, with one single command, all the service are started and your application starts running. Go language is used to write chaincode business logic for the channels. You can also write chaincode in Node.js and Java. Whichever language you decide to use, you need to set up the $GOPATH. You need to set a new prefix for npm to eliminate the need of using sudo while installing packages. The documentation of Hyperledger Fabric provides a script that will download and install samples and binaries to your system. These sample applications installed are useful to learn more about the capabilities and operations of Hyperledger Fabric. This will install 1.4 version of Hyperledger Fabric binaries. The command above downloads and executes a bash script that will download and extract all of the platform-specific binaries you will need to set up your network. It also retrieves some executable binaries that are needed in development and places them in the The above command will bootstrap a sample network with fabcar chaincode installed. You can head to here to learn more about the network that we have just started. After a year of development on Hyperledger Fabric framework, I have realized the importance of getting small things right when setting up the environment. Many errors that you might face during development might well be due to the mistakes in setting up the environment. I hope this guide will help beginners starting to learn this new technology. Please feel free to point out mistakes in this guide. Interested in starting your own blockchain project, but don’t know how? Get in touch at https://xord.solutions/contactUnderstanding the basics
Installing the development environment
Installing cURL
sudo apt-get install curl
Installing Docker
Uninstall previous docker packages.
dpkg -l | grep -i docker
sudo apt-get purge -y docker-engine docker docker.io docker-ce
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
sudo rm -rf /var/lib/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
Set up the repository.
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Install docker.
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Verify that Docker CE is installed correctly.
sudo docker run hello-world
Post installation steps for docker.
sudo groupadd docker
sudo usermod -aG docker $USER
docker run hello-world
Installing docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
Installing Go programming language.
sudo apt-get install golang-go
~/.profile
file.nano ~/.profile
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
source ~/.profile
Installing Node.js package manager.
Installing NPM
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt install nodejs
node -vnpm -v
Post installation steps for NPM.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
~/.profile
file.nano ~/.profile
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
Installing Hyperledger Fabric packages.
curl -sSL http://bit.ly/2ysbOFE | bash -s 1.4.0
bin
sub-directory of the current working directory.
~/.profile
file.nano ~/.profile
export PATH=~/fabric-samples/bin:$PATH
source ~/.profile
Run the sample network
cd fabric-samples/first-network
./byfn.sh up
Conclusion
Get in touch