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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
This accomplishes the following:
a. Clean up system by removing any existing blockchain docker images
b. Generate certificates
crypto-config.yaml
(Crypto configuration file) defines the identity of “who is who”. It tells peers and orderers what organization they belong to and what domain they belong to.c. Create Peers, Orderers and Channel
configtx.yaml
file initializes a blockchain network or channel and services with an Orderer Genesis Block which serves as the first block on a chain. Additionally, membership services are installed on each channel peer (in this case, the Shop and Fitcoin Peers).d. Build docker images of the orderer, peers, channel, network
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
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:
er-compose -p "fitcoin" -f "docker-compose.yaml" up -d
er-compose -p "fitcoin" -f "docker-compose-couchdb.yaml" up -d
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.
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