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.
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
To install python 2.X on Ubuntu, do this:
apt install python2.7
Ensure you have following version of docker & docker-compose
- Docker Engine : 18.03 or above
- docker-compose : 1.11.0 or above
cd $HOME
git clone https://github.com/harsha544/supplier-retailer-app
cd supplier-retailer-app
sh build_ubuntu.sh
nvm install v8.11.2
npm install
cd $HOME/
export PATH=$PATH:$PWD/node_modules/.bin/
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.
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
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
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/
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]
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
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]
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
cd $HOME/supplier-retailer-app/chaincode/composer/
composer card import -f [email protected]
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
cd $HOME/supplier-retailer-app/python/
nohup python database_change_notification_update_insert.py 2>&1 &1