Hyperledger Fabric 2.0 Network Setup on Windows 10
By: Sneha Patil
Tags: Run Test Network, Hyperledger, Hyperledger On Windows, Test Network, Fabric Network Setup

Introduction

Hello folks,

This blog aims to introduce the dev to the concept of natively doing the Hyperledger fabric set up on windows 10.

In this blog, I will show you the complete step by step guide on how to build a Hyperledger fabric network setup on the windows machine.

First, let’s have a look at the prerequisites and get them installed.

Prerequisites —

Install Git

Install git using below command

check the version using below command

"git — version"

Install curl

If curl not been Installed on your machine then please navigate to the below link and get it installed.

Install Docker Desktop

If Docker not been installed on your machine then please navigate to the below link and get it installed.

The Docker Desktop installation includes Docker Engine, Docker CLI client, Docker Compose, Notary, Kubernetes, and Credential Helper.

After installation, we have to start the Docker Desktop. By default, it does not get started hence you have to start it manually. To start it search for docker and select Docker Desktop from the search window result on your machine.

Test your installation —

Open a terminal window (Command Prompt or PowerShell). Run “ docker –version” to ensure that you have a supported version of Docker

“ $ docker –version”

Docker version 19.03.8, build afacb8b

3. Pull the hello-world image from Docker Hub and run a container

“$ docker run hello-world” Unable to find image ‘hello-world:latest’ locally latest: Pulling from library/hello-world 0e03bdcc26d7: Pulling fs layer 0e03bdcc26d7: Verifying Checksum 0e03bdcc26d7: Download complete 0e03bdcc26d7: Pull complete Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1 Status: Downloaded newer image for hello-world:latest

4. List the hello-world image that was downloaded from Docker Hub

“$ docker image ls”

5. List the hello-world container

“$ docker container ls –all”

If you are able to see the result then that's an indication of successful docker installation on your machine.

Congratulations!!! you succeeded in the first part of this article.

Now, let’s move on to the next part of it which is Hyperledger Fabric.

Set up Hyperledger Fabric Network —

Determine a location on your machine where you want to place the fabric-samples repository and enter that folder in a command prompt window.

Clone the hyperledger/fabric-samples repository using below command –

2. Once you are ready, and in the directory into which you will install the Fabric Samples and binaries, go ahead and execute the command to pull down the binaries and images.

Using the Fabric test network —

We are using here fabric test network sample because the test network is being introduced in Fabric v2.0 as the long term replacement for the first-network sample.

Before you can run the test network, you need to clone the fabric-samples repository and download the Fabric images. Make sure that that you have installed the Prerequisites and Installed the Samples, Binaries, and Docker Images which you can find here also.

Bring up the network

You can find the scripts to bring up the network in the test-network directory of the fabric-samples repository. Navigate to the test network directory by using the following command

cd fabric-samples/test-network

From inside the test-network directory, run the following command to remove any containers or artifacts from any previous runs

./network.sh down

You can then bring up the network by issuing the following command.

./network.sh up

2. Creating the channel

Now that we have peer and orderer nodes running on our machine, we can use the script to create a Fabric channel for transactions between Org1 and Org2. Channels are a private layer of communication between specific network members. Channels can be used only by organizations that are invited to the channel, and are invisible to other members of the network.

./network.sh createChannel

If the command was successful, you can see the following message printed in your logs:

========= Channel successfully joined ===========

3. Starting a chaincode on the channel

After you have used the network.sh to create a channel, you can start a chaincode on the channel using the following command

./network.sh deployCC

4. Bring down the network

When you are finished using the test network, you can bring down the network with the following command

./network.sh down

The command will stop and remove the node and chaincode containers, delete the organization crypto material, and remove the chaincode images from your Docker Registry. The command also removes the channel artifacts and docker volumes from previous runs.

Wow, if you are reached till here that means you have successfully executed all the steps and Fabric set up is done on your Windows system.

You should pat yourself on the back for doing a great job.

Congratulations!!! Happy learning!