IBM/CreatingandDeployingBlockchainNetworkUsingHyperlederFabricNodeSDK

Name: CreatingandDeployingBlockchainNetworkUsingHyperlederFabricNodeSDK

Owner: International Business Machines

Description: Create and deploy a blockchain network using Hyperledger Fabric SDK for Node.js

Created: 2018-03-12 23:11:45.0

Updated: 2018-05-20 11:28:53.0

Pushed: 2018-04-30 03:28:07.0

Homepage: https://developer.ibm.com/code/patterns/explore-hyperledger-fabric-through-a-complete-set-of-apis/

Size: 5877

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Creating and Deploying a Blockchain Network using Hyperledger Fabric Node SDK

Instructions for setting the blockchainNetwork

Welcome to Part 1 of building a Blockchain Application. This first pattern is part of a larger application that uses blockchain as a back-end to record fitness activities and manage transactions such as handling acqusition of products via fitcoins. The first step in this series is focused on creating and deploy a Hyperledger Blockchain Network using the Hyperledger Fabric Node SDK. We have two participants, namely a buyer and seller/shop peers. The buyer is the one who downloads the application and subsequently registers his steps on the blockchain. The seller is the one who verifying that the buyer has the right number of fitcoins to make purchases. A developer who has a lite account can run this application locally or adapt it to the IBM Blockchain Starter Plan.

Included Components
Application Workflow Diagram

Application Workflow

Prerequisites
Steps
  1. Run Build.sh Script to build network
  2. Start the Network
  3. Check the logs to see the results
  4. Check the Blockchain Network
1. Run the Build.sh Script

This accomplishes the following:

a. Clean up system by removing any existing blockchain docker images

b. Generate certificates

c. Create Peers, Orderers and Channel

d. Build docker images of the orderer, peers, channel, network

Open a new terminal and run the following command:
rt FABRIC_CFG_PATH=$(pwd)
d +x cryptogen
d +x configtxgen
d +x generate-certs.sh
d +x generate-cfgtx.sh
d +x docker-images.sh
d +x build.sh
d +x clean.sh
ild.sh
2. Start the Network

Make sure the 'LOCALCONFIG' environment variable is unset if you are re-running this step after running the test below

t LOCALCONFIG  

There 2 options to install chaincode on the peer nodes and start the Blockchain network. You can select any one of the following:

3. Check the logs

You will see the results of running the script

Command

er logs blockchain-setup

Output:

ster CA fitcoin-org
egistration complete  FabricCAServices : {hostname: fitcoin-ca, port: 7054}
ster CA shop-org
egistration complete  FabricCAServices : {hostname: shop-ca, port: 7054}
: [EventHub.js]: _connect - options {"grpc.ssl_target_name_override":"shop-peer","grpc.default_authority":"shop-peer"}
: [EventHub.js]: _connect - options {"grpc.ssl_target_name_override":"fitcoin-peer","grpc.default_authority":"fitcoin-peer"}
ult channel not found, attempting creation...
essfully created a new default channel.
ing peers to the default channel.
ncode is not installed, attempting installation...
 container image present.
: [packager/Golang.js]: packaging GOLANG from bcfit
: [packager/Golang.js]: packaging GOLANG from bcfit
essfully installed chaincode on the default channel.
essfully instantiated chaincode on all peers.
4. Check the BlockchainNetwork

Execute the following commands to to test the network by performing the invoke and query operations on the network:

onfiguration
rt LOCALCONFIG=true
 config.js
.
est/
install

If you are using LevelDB, then run the following command:

 index.js

If you are using CouchDB, then run the following command:

 indexCouchDB.js
Additional Resources
License

Apache 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.