Skip to main content

Setup development environment for Hyperledger composer on windows



There is no direct best ( or at least I don’t know ) way to create a good development environment for the hyper ledger composer on windows. I have installed hyper ledger on windows and it’s also not working satisfactorily. I want to develop in windows while want to run it smoothly like in Ubuntu.

So the way I found is virtual box and ssh.

Vagrant is kind of the thing that gives this readymade. But .box file we need to download is very slow in speed [ 150 kbps] and for me, it was disconnecting continuously. So I left the vagrant and find another way to get the facility provided by the vagrant.

I am going to show the way I created my development environment.

You Need 

That's it. If you have this two things you are ready to go.


Prepare Ubuntu Server Virtual Box Machine


Either install ubuntu 16.04 on the virtual box or import the ubuntu server virtual machine to the Virtual Box.

Add ubnut server virtual box machine
Add Ubuntu server virtual box machine


Open Virtual Machine and install OpenSSH So we can access the VirtualBox machine via ssh from the host os [ windows]

Install OpenSSH Server 


Command To install Openssh server
$ sudo apt-get install openssh-server 



Install open ssh on the ubuntu server machine
Install open ssh on the ubuntu server machine


Set Port Forwarding 


Now make port forwarding to access the ssh of the virtual machine

Goto the network tab of the virtual machine 
  • select network tab 
  • add an entry of ssh 
    • ssh host port: 3022
    • guest port: 22 
  • hyperledger composer playground
    • host port: 10020 
    • guest  port:8080

set port forwarding
set port forwarding 

Set Shared folder

It's actually essential to create a shared folder which is mounted to the ubuntu server VirtualBox machine. So we can use our windows editors to create and modify the files while it also accessible by the ubuntu server VirtualBox machine to execute the code.

To create a shared folder you first need to install the VirtualBox-guest-additions-iso

install virtualbox-guest-additions-iso
install VirtualBox-guest-additions-iso

Traverse to the /usr/share/virtualbox you will find here the VirtualBox-guest-additions.iso file

Mount folder
Mount folder

To install guest additions programs follow the steps

Mount the iso file using mount function 

Command to ssh to mount guest addition iso

/usr/share/virtualbox $ sudo mount VBoxGuestAdditions.iso /media/cdrom 
// Note the path here //


Install the guest additions iso


Command to install the guest additions iso

ub@ubuntu:/$ sudo /media/cdrom/VBoxLinuxAddtions.run

Mount and install the virtualbox-guest-additiosn-iso
Mount and install the virtualbox-guest-additions-iso

after installing the iso reboot the virtualbox machine and run the following commands


Command to add the current user the vboxsf  group

$ sudo usermod -a -G vboxsf ub



Make a shared folder in the virtualbox 


Shared Folder
Shared Folder

Mount the Windows Share folder on the Ubuntu server 

Mount Shared folder inside the Ubunut Server VirtualBox Machine
Mount Shared folder inside the Ubuntu Server VirtualBox Machine

Setup Hyperledger Composer pre-requests


Now as we have enabled the ssh and also done the port forwarding we can ssh in our virtualbox machine and set up the hyperledger composer.

Start Ubuntuuntu server machine, Open your favourite ssh client [ for me its cmd 😏 ] and ssh through the forwarded port [ that is 3022]


Command to ssh to your vm [ if you are using cmd ]

cmd :  ssh -p 3022 [username you set in vm during installation]@127.0.0.1 
// p stands for port number



ssh to your ubuntu server virtualbox  machine
ssh to your ubuntu server virtualbox  machine

Now  run (copy/paste) the following command in the cmd/ssh-client 


curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh

chmod u+x prereqs-ubuntu.sh

Upper command will 
  • fetch the shell  script configured to install the programs required for hyperledger composer and 
  • make the file executable 


$ ./prereqs-ubuntu.sh

Upper Command will
  • execute the file we just fetched and install all the required programs for the hyperledger composer


After completion of the script, your ubuntu server virtualbox machine is ready to set up the hyperledger-composer on it.


Setup Hyperledger-composer


Through ssh run the following commands as well

$ npm install -g composer-cli
$ npm install -g composer-rest-server
$ npm install -g generator-hyperledger-composer
$ npm install -g yo

It's time to install the hyperledger composer playground 

$ npm install -g composer-playground


Install Hyperledger-Fabric 



$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
$ tar -xvf fabric-dev-servers.tar.gz
[ This command will fetch the fabric-dev-server and extract it ]

$ cd ~/fabric-tools
$ ./downloadFabric.sh
[ This command will fetch the hyperledger fabric - docker images - will take very long ]


$ cd ~/fabric-tools

$ ./startFabric.sh

$ ./createPeerAdminCard.sh
[ This command will do initail seeding for you ]



after you followed all the steps run the final command 

  $  composer-playground
[ This command will spin up the hyper ledger ]

goto the web browser in windows and goto the url
127.0.0.1:10020

you should get this output

hyperledger comopser on windows using  ubuntu virtualbox machine
hyperledger composer on windows using ubuntu virtualbox machine

Hope you find it useful.

All shell command for install of hyperledger shown here is copied from Hyperledger composer website.

Comments

Popular posts from this blog

Google blogger Ideas panel

Google blogger Ideas  I opened by blogger today, and..   I got this.  Google blogger Ideas  A panel suggesting a topic on which I can write my next blog. It's fetching unanswered question from web according to your previous post and topics. It was something, I was really looking for, after all it takes time to finding subject on which to write next and still being in the same niche.  Awesome feature Blogger! 

Apache : setup basic auth with apache in windows

Authentication is any process by which you verify that someone is who they claim they are. Authorization is any process by which someone is allowed to be where they want to go or to have information that they want to have. I will show here how to set up basic auth on the apache with windows. Pre-requests  Windows VPS Apache server ( That's it ) ( In windows it might be difficult to setup the Apache alone. So instead use something ling xampp , wamp or laragon .) RestClient (  I personally use the postman , but you can use your preferable client)  Windows VPS provider Steps  Enable the necessary modules in the Apache Create the password file Set the auth directives in the virtual host file. Verify basic auth. Enable the  necessary   modules  in the Apache Open the httpd.conf file in the apache's conf folder. httpd.conf file Enable the necessary modules to make the basic auth working. Necessary modules  mod_auth_basic

Firebase - update a spacific fields of single element of object of array in firestore

Firebase - update a spacific fields of single element of object of array in firestore  Its actully advisable to use map instead of array when ever it is possible. But, there are cetain cases where you don't have option to do so.  For example, you are directly saving the response from some outer source without any modification and they send you an array. In this case you will have array to work with. Firestore does not support array here is why  "bad things can happen if you have multiple clients all trying to update or delete array elements at specific indexes. In the past, Cloud Firestore addressed these issues by limiting what you can do with arrays " For more details information you can refer to Kato Richardson post Best Practices: Arrays in Firebase .  Firestore document having array [ used from stackoverflow question ] Suppose you have array of object something like shown in array. Now you want to update endTime field of the object on the index [1]