fabric-samples
fabric-samples copied to clipboard
Chaincode definition for 'basic' exists, but chaincode is not installed
I installed fabric 2.0 and fabric samples,followed the tutorial https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html
After I ran the instruction ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript -ccl javascript
,
I checked the docker by using docker ps -a
, but couldn't find any chaincode containers. When I tried to run peer chaincode invoke InitLedger
, I got the result like this:
Error: endorsement failure during invoke. response: status:500 message:"make sure the chaincode basic has been successfully defined on channel mychannel and try again: chaincode definition for 'basic' exists, but chaincode is not installed"
I checked peer0.org1 docker logs, they showed the same problem: WARN [endorser] ProcessProposal -> Failed to invoke chaincode channel=mychannel chaincode=basic error="make sure the chaincode basic has been successfully defined on channel mychannel and try again: chaincode definition for 'basic' exists, but chaincode is not installed"
I don't think this problem was caused by package_id because I followed the tutorial step by step and everything went well before invoking the InitLedger
function, can anyone solve this problem?Thanks a lot!
I'm using Ubuntu18.04 vm machine in windows10, running fabric in docker. I can provide full docker logs if you need.
I removed two lines in the source code in test-network/scripts/ccutils.sh in functions installChaincode and queryInstalled:
before:
peer lifecycle chaincode queryinstalled --output json | jq -r 'try (.installed_chaincodes[].package_id)' | grep ^${PACKAGE_ID}$ >&log.txt
peer lifecycle chaincode queryinstalled --output json | jq -r 'try (.installed_chaincodes[].package_id)' | grep ^${PACKAGE_ID}$ >&log.txt
after:
peer lifecycle chaincode queryinstalled --output json
(in function installCaincode)
peer lifecycle chaincode queryinstalled --output json
(in function queryInstalled)
Hi @Light7Rain, I would recommend you to use the below reference to setup your HLF blockchain network: https://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html#set-up-the-blockchain-network
This worked for me, chaincode containers are up & running.
Utilize the following commands below Verify Chaincode Installation: Run the following command to check if the chaincode is already installed on the peer: peer lifecycle chaincode queryinstalled --peerAddresses <peer_address> --channelID <channel_id> --output json
Run the following command to check if the chaincode definition exists on the channel: peer lifecycle chaincode querycommitted --channelID <channel_id> --name <chaincode_name>
Verify Chaincode Package ID: Double-check the package_id value you are using when installing the chaincode. Make sure it matches the actual package ID generated during the chaincode package step. You can use the following command to check the package ID:
peer lifecycle chaincode queryinstalled --output json
Compare the package ID returned by this command with the one you used during installation.
If none of the above steps resolve the issue, you can try cleaning up your Fabric network by stopping and removing all Docker containers, deleting any generated crypto material, and then starting the network again from scratch.
Hope it helps ! Cheers