// This bash file contains the Code for beploying the Smart Contracts from Organization 1 and 2 for the Peer1 and Peer2 participating in the Transcript Verification Process based on Blockchain Prototype Model of the proposed research. 
#!/bin/bash

CCITs - iMac:~ccit$ / bin / bash - c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)b

CCITs-iMac:~ ccit$ brew --version

CCITs-iMac:~ ccit$ brew install git

CCITs-iMac:~ ccit$ git --version

CCITs-iMac:~ ccit$ brew install curl

CCITs-iMac:~ ccit$ curl --version

CCITs-iMac:~ ccit$ docker --version

CCITs-iMac:~ ccit$ brew install go@1.17.5

CCITs-iMac:~ ccit$ go version

CCITs-iMac:~ ccit$ brew install jq

CCITs-iMac:~ ccit$ jq --version

CCITs-iMac:~ ccit$ mkdir -p $HOME/go/src/hyperledger && cd $HOME/go/src/hyperledger

CCITs-iMac:hyperledger ccit$ curl -sSL https://bit.ly/2ysbOFE | bash -s

CCITs-iMac:hyperledger ccit$ cd fabric-samples/test-network

CCITs-iMac:test-network ccit$ ./network.sh down && ./network.sh up

CCITs-iMac:test-network ccit$ docker ps -a

CCITs-iMac:test-network ccit$ ./network.sh createChannel

CCITs-iMac:test-network ccit$ cd ../chaincode/fabcar/go && GO111MODULE=on go mod vendor && cd ../../../test-network

CCITs-iMac:test-network ccit$ export PATH=${PWD}/../bin:${PWD}:$PATH

CCITs-iMac:test-network ccit$ export FABRIC_CFG_PATH=$PWD/../config/

CCITs-iMac:test-network ccit$ peer lifecycle chaincode package fabcar.tar.gz --path ../chaincode/fabcar/go/ --lang golang --label fabcar_1

CCITs-iMac:test-network ccit$ ls | grep fabcar.tar.gz

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ENABLED=true

CCITs-iMac:test-network ccit$ export CORE_PEER_LOCALMSPID=" Org1MSP "

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp

CCITs-iMac:test-network ccit$ export CORE_PEER_ADDRESS=localhost:7051

CCITs-iMac:test-network ccit$ peer lifecycle chaincode install fabcar.tar.gz

CCITs-iMac:test-network ccit$ export CORE_PEER_LOCALMSPID=" Org2MSP "

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp

CCITs-iMac:test-network ccit$ export CORE_PEER_ADDRESS=localhost:9051

CCITs-iMac:test-network ccit$ peer lifecycle chaincode install fabcar.tar.gz

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ENABLED=true

CCITs-iMac:test-network ccit$ export CORE_PEER_LOCALMSPID=" Org1MSP "

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp

CCITs-iMac:test-network ccit$ export CORE_PEER_ADDRESS=localhost:7051

CCITs-iMac:test-network ccit$ peer lifecycle chaincode queryinstalled

CCITs-iMac:test-network ccit$ CC_PACKAGE_ID=fabcar_1:1146b4b491871bf18b23dd67dd8cc058655b36cc0e2274f165ed06b796a8f276

CCITs-iMac:test-network ccit$ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name fabcar --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

CCITs-iMac:test-network ccit$ export CORE_PEER_LOCALMSPID=" Org2MSP
  "

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp

CCITs-iMac:test-network ccit$ export CORE_PEER_ADDRESS=localhost:9051

CCITs-iMac:test-network ccit$ peer lifecycle chaincode queryinstalled

CCITs-iMac:test-network ccit$ CC_PACKAGE_ID=fabcar_1:1146b4b491871bf18b23dd67dd8cc058655b36cc0e2274f165ed06b796a8f276

CCITs-iMac:test-network ccit$ peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name fabcar --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

CCITs-iMac:test-network ccit$ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --output json

CCITs-iMac:test-network ccit$ peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls true --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

CCITs-iMac:test-network ccit$ peer lifecycle chaincode querycommitted --channelID mychannel --name fabcar --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem


