Installing Hyperledger Fabric on windows and Deploy /Start chain code
Tags: blockchain, hyperledgerfabric, installation, beginners
Published: 2022-06-15 21:35:41

#Windows Installation
Below are the instructions to intall and run chain code on a windows machine. 
For this installation, you should be prepared for some obstacles as installation on windows is not simple. 

####Pre-reqs 
•	Docker (https://docs.docker.com/desktop/windows/install/)
•	cURL (https://curl.se/download.html)
•	Go (https://go.dev/dl/)
•	Node.js (https://nodejs.org/en/download/)
•	Git (https://git-scm.com)

Download, if needed and check on each pre-requisite item 
####Validatation for pre-reqs
Run command prompt in admin mode (cmd) check all installations 

  cURL Version
  ![Check cUrl Version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mb04f1kt0bcrqagyztas.GIF)

docker version 
 ![docker version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/maiqlzec86ni05p6cotz.GIF)

git version 
![git version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1w9l9mt62sf5rls0l17w.GIF)

go version
![go version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rfj0lpz9520ypowu15f.GIF)

Node version
![Node version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qgf0p6tw0aiz50jqsj3n.GIF)

npm version 
![npm version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukfdze4pk5djlqzxp27g.GIF)

###Let's proceed to install other items 


WSL (https://docs.microsoft.com/en-us/windows/wsl/install)
Use this command to install Windows Subsystem for Linux (WSL) -  `wsl –install`
To update : WSL2 Linux kernel update package for x64 machines (https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi)

Use this command to validate installation `wsl -l -v`
Check Windows Feature if it has been installed, do check the **Virtual Machine Platform**, if not done set.
#####WSL and Virtual Machine Platform 
![WSL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xgydfxhsg2i4320uukp.GIF)

Once done, log in Microsoft app store and download Ubantu and Windows Terminal 
Run Windows Terminal under Admin mode 
Below screen shows, how it looks after installation. 
Note: Open Windows Terminal in Admin mode
![Ubantu and Windows Terminal installation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z9srbj0gfqa2fax6e8yd.png)

Once Ubantu starts, it will ask for username and password. 
Ubantu is picky with user names.. just like Unix, it needs to start with lower case (https://www.oreilly.com/library/view/practical-unix-and/0596003234/ch04s01.html) 

![Ubantu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8b85b2smh2viypnbvxd3.GIF)

![User name and password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rn0r75twb6306gqtkih.GIF)

####Docker desktop app start
Run docker under admin mode and under setting-> resources see that Ubantu is selected (First time users, will have to create docker hub ID)
Make sure
1.	WSL 2 is checked 
2.	Ubantu is being referenced


![Docker WSL check](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oa1v8xkvvo0e7pbxih60.GIF)

Enable Ubantu on docker container
![Enable Ubantu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmcrilm93bt90930hl0f.GIF)


####Installing Hyperledger Fabric and Binaries 
•	Clone the hyperledger/fabric-samples repository.
I’m installing Hyperledger fabric version **2.2.0** 
`curl -sSL http://bit.ly/2ysbOFE | bash -s -- <fabric_version> <fabric-ca_version> <thirdparty_version>`
`curl -sSL http://bit.ly/2ysbOFE | bash -s -- 2.2.0 1.4.9 0.4.22`

####Read this doc before you move ahead (https://hyperledger-fabric.readthedocs.io/en/release-1.4/developapps/scenario.html)

Read this doc to aid in testing (https://hyperledger-fabric.readthedocs.io/en/release-2.2/test_network.html)
`cd fabric-samples/test-network`

###Step by step testing and running chain code 
![hyperledger fabric sample](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5z95id3p2v3evnxxtio.GIF)

Probe the folder `ls` 
![Hyperledger Fabric -2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfx958v2b4dmdelkcwl9.GIF)

Start the network with script file `./network.sh up`
Note: run `./network.sh down` to take anything running down on docker. 
check existing processes running by using : `docker ps -a`
![Hyperledger Fabric -3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3hikilrcn6bpfs7xyar.GIF)

Create mychannel `./network.sh up createChannel`
![Hyperledger Fabric -4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lgzcg578g2ay4dbqs9dm.GIF)

Deploying the chain code `./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript -ccl javascript
`
![Hyperledger Fabric -5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmkrmevw9jf42cgupol2.GIF)


![Hyperledger Fabric -6](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/txo16lt0q5mt1tapeudx.GIF)


Docker container showing images created
![Hyperledger Fabric -7](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qmytnszwxiw1yis627uc.GIF)


Note: in the end run `./network.sh down` to stop process. Check docker's to confirm all processes are stopped..