Skip to content

krishvoor/supplier-retailer-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequisites

Before we begin, if you haven’t already done so, you may wish to check that you have all the prerequisites below installed on the platform(s) on which you’ll be setting up supplier-retailer-app.

Install nvm


To install nvm, you can do this using cURL:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

or Wget:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Install python


To install python 2.X on Ubuntu, do this:

apt install python2.7

Docker & docker-compose


Ensure you have following version of docker & docker-compose

  • Docker Engine : 18.03 or above
  • docker-compose : 1.11.0 or above

Bootstrapping the Environment

Step1: Clone the repository


cd $HOME
git clone https://github.com/harsha544/supplier-retailer-app

Step 2: Change Directory


cd supplier-retailer-app

Step 3: Bring up Blockchain Network


sh build_ubuntu.sh

Step 4: Use Node v8.11.2


nvm install v8.11.2

Step 5: Installing composer utilities


npm install

Step 6: Update PATH to include composer binaries


cd $HOME/
export PATH=$PATH:$PWD/node_modules/.bin/

Step 7: Update Supplier-Peer PEM Values in $PWD/composer/supplier-retailer.json


cd $HOME/supplier-retailer-app

  • awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cli/peers/peerOrganizations/supplier1-org/peers/supplier1-peer/tls/ca.crt > composer/supplier1Peer/supplier1-ca.txt
    cat composer/supplier1Peer/supplier1-ca.txt

  • awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cli/peers/peerOrganizations/supplier2-org/peers/supplier2-peer/tls/ca.crt > composer/supplier2Peer/supplier2-ca.txt
    cat composer/supplier2Peer/supplier2-ca.txt

  • awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cli/peers/peerOrganizations/supplier3-org/peers/supplier3-peer/tls/ca.crt > composer/supplier3Peer/supplier3-ca.txt
    cat composer/supplier3Peer/supplier3-ca.txt

for i in 1 2 3 ; do  printf "\n supplier$i \n"; cat composer/supplier"$i"Peer/supplier"$i"-ca.txt ; done

Open composer/supplier-retailer.json and update
INSERT_ORG1_CA_CERT , INSERT_ORG2_CA_CERT, INSERT_ORG3_CA_CERT
with supplier$i values from above respectively.

Step 8: Update Orderer PEM Values in $PWD/composer/supplier-retailer.json


awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cli/peers/ordererOrganizations/orderer-org/orderers/orderer0/tls/ca.crt > composer/orderer-ca.crt
cat composer/orderer-ca.crt
Open composer/supplier-retailer.json and update INSERT_ORDERER_CA_CERT with above value

Step 9: Customizing the connection profile for respective supplier organization


cp composer/supplier-retailer.json composer/supplier-retailer_org.json

Update this block of code between sections version and channels, via which we enforce timeout period in supplier-retailer_org.json

"client": { 
        "organization": "SupplierXOrg",
        "connection": { 
            "timeout": { 
                "peer": { 
                    "endorser": "300",
                    "eventHub": "300",
                    "eventReg": "300"
                },
                "orderer": "300"
            }
        }
    },

Copy above generated supplier-retailer_org.json to respective supplierXPeer

cp composer/supplier-retailer_org.json composer/supplier1Peer/supplier-retailer-org1.json
cp composer/supplier-retailer_org.json composer/supplier2Peer/supplier-retailer-org2.json
cp composer/supplier-retailer_org.json composer/supplier3Peer/supplier-retailer-org3.json

P.S

Ensure you update "organization": "SupplierXOrg" for respective Supplier accordingly in each supplier-retailer-orgX.json , where X=1,2,3

Step 10: Locating the certificate and private key for the Hyperledger Fabric administrator for each Supplier


Locating certificates files respective supplier i.e identifying public part of identity for the users usually found under signcerts

export ORG1=cli/peers/peerOrganizations/supplier1-org/users/Admin@supplier1-org/msp/
export ORG2=cli/peers/peerOrganizations/supplier2-org/users/Admin@supplier2-org/msp/
export ORG3=cli/peers/peerOrganizations/supplier3-org/users/Admin@supplier3-org/msp/

cp -p $ORG1/signcerts/A*.pem composer/supplier1Peer/
cp -p $ORG2/signcerts/A*.pem composer/supplier2Peer/
cp -p $ORG3/signcerts/A*.pem composer/supplier3Peer/

Identify private key for the user which is used for signing transactions and found under keystore

cp -p $ORG1/keystore/*_sk composer/supplier1Peer/

cp -p $ORG2/keystore/*_sk composer/supplier2Peer/

cp -p $ORG3/keystore/*_sk composer/supplier3Peer/

Step 11: Creating business network cards for the Hyperledger Fabric administrator for all Orgs


cd $HOME/supplier-retailer-app/composer/

  • composer card create -p supplier1Peer/supplier-retailer-org1.json -u PeerAdmin -c supplier1Peer/[email protected] -k supplier1Peer/*_sk -r PeerAdmin -r ChannelAdmin -f supplier1Peer/[email protected]

  • composer card create -p supplier2Peer/supplier-retailer-org2.json -u PeerAdmin -c supplier2Peer/[email protected] -k supplier2Peer/*_sk -r PeerAdmin -r ChannelAdmin -f supplier2Peer/[email protected]

  • composer card create -p supplier3Peer/supplier-retailer-org3.json -u PeerAdmin -c supplier3Peer/[email protected] -k supplier3Peer/*_sk -r PeerAdmin -r ChannelAdmin -f supplier3Peer/[email protected]

Step 12: Importing the business network cards for the Hyperledger Fabric administrator for all Orgs


composer card import -f supplier1Peer/[email protected] --card PeerAdmin@supplier-retailer-org1
composer card import -f supplier2Peer/[email protected] --card PeerAdmin@supplier-retailer-org2
composer card import -f supplier3Peer/[email protected] --card PeerAdmin@supplier-retailer-org3

Issue composer card list to verify whether cards have been imported successfully or not

Step 13: Installing the business network onto the Hyperledger Fabric peer nodes


cd $HOME/supplier-retailer-app/chaincode/composer/
composer network install --card PeerAdmin@supplier-retailer-org1 --archiveFile [email protected]
composer network install --card PeerAdmin@supplier-retailer-org2 --archiveFile [email protected]
composer network install --card PeerAdmin@supplier-retailer-org3 --archiveFile [email protected]

Step 14: Starting the business network


cd $HOME/supplier-retailer-app/composer
composer network start -n retailer-supplier -A admin -S adminpw -V 0.0.2-deploy.6 -c PeerAdmin@supplier-retailer-org1

Step 15: Importing a business network card to access the business network


cd $HOME/supplier-retailer-app/chaincode/composer/
composer card import -f [email protected]

Step 16: Generating the REST APIs server


cd $HOME/supplier-retailer-app/composer

Invoke composer-rest-server to start REST Server on http://localhost:8080

composer-rest-server
? Enter the name of the business network card to use: admin@retailer-supplier
? Specify if you want namespaces in the generated REST API: never use namespaces
? Specify if you want to use an API key to secure the REST API: No
? 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

Step 17: Start DCN Notifications services in background


cd $HOME/supplier-retailer-app/python/
nohup python database_change_notification_update_insert.py 2>&1 &1

About

Sample Supplier/Retailer application using Hyperledger Fabric

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 84.6%
  • CSS 11.8%
  • HTML 2.8%
  • Shell 0.5%
  • Python 0.2%
  • Dockerfile 0.1%