Install hyper ledger fabric and develop business network application

Below steps are use to install Hyperledger Fabric and develop business network application
@ UBUNTU 16.04 LTS (64 bits):


                curl -O https://hyperledger.github.io/composer/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
./prereqs-ubuntu.sh
npm install -g composer-cli
npm install -g composer-rest-server
npm install -g generator-hyperledger-composer
npm install -g yo
npm install -g composer-playground
sudo mkdir ~/fabric-tools && cd ~/fabric-tools
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip
unzip fabric-dev-servers.zip   -->unzip command should execute in /fabric-tools directory
cd ~/fabric-tools
./downloadFabric.sh   – should run under fabric-tools dir





1.        HYPER LEDGER DEVELOPMENT STEPS

                Step 1-  yo hyperledger-composer:businessnetwork
                             To Create Business Network Defination will use below command, it will ask you to make multiple entries as shown. This     command will create project structure. Yo man will be use to create business network application structure.
Example : tutorial-network location -- /home/mahensha/tutorial-network

                Step 2 - Start visual studio code. Open tutorial-network folde
























Step 3- Write down the model as below:


Step 4- Write down the transaction logic as below:






Step 5 -Create new permission file as below:




































Step 6 – go to the terminal again --Create bna file (this is a archive file to be deploy)
  cd tutorial-network
  run :
  composer archive create -t dir  -n

































Step 7 - Start hyper ledger fabric.
   go to fabric-tools , run
   cd ~/fabric-tools     --/root/fabric-tools
   ./startFabric.sh

 

 












Step 8- Create Admin Card

   go to fabric-tools , run
   cd ~/fabric-tools
   ./createPeerAdminCard.sh




















 
















Step 9 - Install business network  at run time of composer. Command as below: 

Move to tutorial-network directory and then run below command: below commad require business network card , which we have cretaed previous step.

composer runtime install --card PeerAdmin@hlfv1 --businessNetworkName tutorial-network










Step 10- start Network Admin Card 
Go to tutorial-network , by executing:
  cd tutorial-network
  and  run below command:
  composer network start --card  PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile tutorial-network@0.0.1.bna --file networkadmin.card
















Step 11- Import admin network card; command as below:

go to tutorail-network dir:
 cd /home/mahensha/tutorial-network
 run :
 composer card import –file networkadmin.card

 and then ping the network , with:
 composer network ping –card admin@tutorial-network


To import network card:


 mahensha@mahendra-Vostro-15-3568:~/tutorial-network$ composer card import --file networkadmin.card

Successfully imported business network card
            Card file: networkadmin.card
            Card name: admin@tutorial-network

Command succeeded

Step 12 -To ping network card:

mahensha@mahendra-Vostro-15-3568:~/tutorial-network$ composer network ping --card admin@tutorial-network
The connection to the network was successfully tested: tutorial-network
            version: 0.16.4
            participant: org.hyperledger.composer.system.NetworkAdmin#admin

Command succeeded

NOTE –HYPER LEDGER SHOULD RUN , WHILE EXECUTING ABOVE COMMANDS.

Step 13 – To create rest service/api:

  go to tutorial-networks , and run below command:
  composer-rest-server



mahensha@mahendra-Vostro-15-3568:~/tutorial-network$ composer-rest-server
? Enter the name of the business network card to use: admin@tutorial-network
? Specify if you want namespaces in the generated REST API: never use namespaces
? Specify if you want to enable authentication for the REST API using Passport: No
? Specify if you want to enable event publication over WebSockets: Yes
? Specify if you want to enable TLS security for the REST API: No

To restart the REST server using the same options, issue the following command:
   composer-rest-server -c admin@tutorial-network -n never -w true

Discovering types from business network definition ...
Discovered types from business network definition
Generating schemas for all types in business network definition ...
Generated schemas for all types in business network definition
Adding schemas for all types to Loopback ...
Added schemas for all types to Loopback
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer


Now you can check all of your API @
localhost:3000


Comments