问题
I've followed 2 different tutorials
https://github.com/swetharepakula/Fabric101Workshop and
https://hyperledger-fabric.readthedocs.io/en/release-2.0/deploy_chaincode.html.
Both times when I query installed it shows fabcar is installed and it commits successfully, but in both when I try to invoke I receive the following:
Error: endorsement failure during invoke. response: status:500 message:"make sure the chaincode fabcar has been successfully defined on channel mychannel and try again: chaincode definition for 'fabcar' exists, but chaincode is not installed".
I've tried changing CORE_PEER_GOSSIP_USELEADERELECTION=true
, but this stopped one of my peer nodes from starting up.
I'm working on a Mac and the nodes are running in docker, any help would be greatly appreciated.
回答1:
You will have to install the chaincode first and then invoke it. You can follow the steps mentioned in this link in order to install, instantiate and then invoke the chaincode.
回答2:
It seems like your chaincode is not installed on the peers of all the organizations.You installed it on a peer of an organization and trying to query from another peer where it does not exist. And also follow the chaincode lifecycle (6 steps) from the documentation.
https://hyperledger-fabric.readthedocs.io/en/release-2.0/commands/peerlifecycle.html
回答3:
I had the same problem when I packaged the chaincode using Go. Then I restarted the test network and tried to package the chaincode using Java, problem solved.
回答4:
I've had this error when I used the wrong packageID when approving on one of the organization
When using approveformyorg
, checkout that you use respective $PACKAGE_ID_ORG1
and $PACKAGE_ID_ORG2
:
On org1 :
peer lifecycle chaincode approveformyorg \
--channelID $CHANNEL_NAME \
--name $CHAINCODE_NAME --version $CC_VERSION \
--package-id $PACKAGE_ID_ORG1 \
--sequence $CC_SEQ -o orderer:7050 --tls --cafile $ORDERER_TLS_CA
On org2 :
peer lifecycle chaincode approveformyorg \
--channelID $CHANNEL_NAME \
--name $CHAINCODE_NAME --version $CC_VERSION \
--package-id $PACKAGE_ID_ORG2 \
--sequence $CC_SEQ -o orderer:7050 --tls --cafile
Otherwise it would give me the following info :
On org1:
bash-5.0# peer lifecycle chaincode queryapproved -C bankscochannel -n fabcar
Approved chaincode definition for chaincode 'fabcar' on channel 'bankscochannel':
sequence: 1, version: 1.0, init-required: false, package-id: fabcar-v1:002d3fc291572c3e8bc52fea3b228cbd1877ab87669978759fc75f51f893a0dd, endorsement plugin: escc, validation plugin: vscc
bash-5.0# peer lifecycle chaincode querycommitted -C bankscochannel
Committed chaincode definitions on channel 'bankscochannel':
Name: fabcar, Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc
bash-5.0# peer lifecycle chaincode queryinstalled
Installed chaincodes on peer:
Package ID: fabcar-v1:002d3fc291572c3e8bc52fea3b228cbd1877ab87669978759fc75f51f893a0dd, Label: fabcar-v1
0n org2:
bash-5.0# peer lifecycle chaincode queryapproved -C bankscochannel -n fabcar
Approved chaincode definition for chaincode 'fabcar' on channel 'bankscochannel':
sequence: 1, version: 1.0, init-required: false, package-id: fabcar-v1:002d3fc291572c3e8bc52fea3b228cbd1877ab87669978759fc75f51f893a0dd, endorsement plugin: escc, validation plugin: vscc
bash-5.0# peer lifecycle chaincode querycommitted -C bankscochannel
Committed chaincode definitions on channel 'bankscochannel':
Name: fabcar, Version: 1.0, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc
bash-5.0# peer lifecycle chaincode queryinstalled
Installed chaincodes on peer:
Package ID: fabcar-v1:c4430b8d45ee5bca03233272da19aafab73d41c973861adfab8d349c70d950e3, Label: fabcar-v1
Note that in the console output the result of both peer lifecycle chaincode queryapproved
return the same package_id which is not correct
来源:https://stackoverflow.com/questions/60939652/in-hyperledger-fabric-when-i-try-to-invoke-im-getting-the-following-error-cha