What I want to do (the short part of the post)
I want run a project below successfuly
The problem
I installed a blockchain project from GitHub,which is built with Node.js and HyperlederFabric V2.1.This is its link:https://github.com/TasinIshmam/blockchain-academic-certificates. After completely installing according to its instructions, I ran the web-frontend and found no errors in "register" or "login", but when I clicked the "issue" button in the "university" page, there were some errors:
Schema v1 does not exist
Error: Schema v1 does not exist
at SingleQueryHandler.evaluate (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/node_modules/fabric-network/lib/impl/query/singlequeryhandler.js:41:27)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Transaction.evaluate (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/node_modules/fabric-network/lib/transaction.js:275:25)
at async Object.invokeChaincode (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/services/fabric/chaincode.js:65:32)
at async generateMerkleTree (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/services/encryption.js:17:22)
at async Object.generateMerkleRoot (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/services/encryption.js:41:18)
at async Object.issueCertificate (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/services/university-service.js:25:22)
at async postIssueCertificate (/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/web-app/controllers/university-controller.js:73:31)
Solutions that I tried
I have asked some people for help,but most of them also did not know why, and one of them said I probably did not package the chaincode well. Actually, I am 100% sure that I packaged the chaincode using the correct path and method. Besides,I tried to read and understand the source code but failed...
These are my whole installation records below:(I use AWS EC2 with Ubuntu 20)
#step1 install go 1.1.9
wget https://studygolang.com/dl/golang/go1.19.linux-amd64.tar.gz
tar -xzf go1.19.linux-amd64.tar.gz
rm -rf go1.19.linux-amd64.tar.gz
mv go/ /usr/local/
echo 'export GOROOT=/usr/local/go'>> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
#step2 install docker and docker-compose
sudo apt-get update
sudo apt install docker.io
sudo apt install docker-compose
#step3 install mongodb 4.4
sudo apt-get install gnupg curl
curl -fsSL https://pgp.mongodb.com/server-4.4.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-4.4.gpg \
--dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org=4.4.23 mongodb-org-server=4.4.23 mongodb-org-shell=4.4.23 mongodb-org-mongos=4.4.23 mongodb-org-tools=4.4.23
sudo systemctl start mongod
sudo systemctl status mongod
#step4 install node 12
cd ~
curl -sL https://deb.nodesource.com/setup_12.x -o setup_12.sh
sh ./setup_12.sh
sudo apt update
sudo apt install nodejs
node -v
#step5 install dotenv tool
npm install dotenv -g
#step6 install hyperledger fabric 2.1.0 and run
mkdir -p /root/go/src/github.com/hyperledger
cd /root/go/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
cd fabric/
git checkout v2.1.0
cd scripts/
./bootstrap.sh
cd fabric-samples/test-network
./network.sh up createChannel -ca -c mychannel -s couchdb
#step7 install the project mentioned before and instll chaincode in fabric,by the way,"FABRIC_CHAINCODE_NAME"in .env file should be fabcar in this case.if you set the value "fabcar_1",it will failed when you login in web-frontend.
cd ..
cd chaincode
git clone https://github.com/TasinIshmam/blockchain-academic-certificates.git
cd blockchain-academic-certificates/web-app
npm install
npm install --only=dev
touch .env
echo 'MONGODB_URI_LOCAL = mongodb://localhost:27017/blockchaincertificate'>> .env
echo 'PORT = 3000'>> .env
echo 'LOG_LEVEL = info'
echo 'EXPRESS_SESSION_SECRET = sdfsdfddfgdfg3242efDFHI234'>> .env
echo 'CCP_PATH =/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.json'>> .env
echo 'FABRIC_CHANNEL_NAME = mychannel'>> .env
echo 'FABRIC_CHAINCODE_NAME = fabcar'>> .env
cd ..
cd chaincode
npm i
cd /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/test-network
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
peer lifecycle chaincode package fabcar.tar.gz --path /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/chaincode/ --lang node --label fabcar_1
export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:7051
peer lifecycle chaincode install fabcar.tar.gz
export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:9051
peer lifecycle chaincode install fabcar.tar.gz
#the command above will return a "PACKAGE_ID",add it below,just like"export CC_PACKAGE_ID=fabcar_1:69de748301770f6ef64b42aa6bb6cb291df20aa39542c3ef94008615704007f3"
export CC_PACKAGE_ID=fabcar_1:
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 --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
CORE_PEER_LOCALMSPID="Org1MSP"
CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_ADDRESS=localhost:7051
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 --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --output json
peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --channelID mychannel --name fabcar --version 1.0 --sequence 1 --tls --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
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
cd /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/blockchain-academic-certificates/wep-app
npm run start-development
#step 8 Finnaly opening browser and access localhost:3000
Could you give me some advice after repeating the steps above?
I appreciate!