Search code examples
hyperledger-fabrichyperledgerhyperledger-chaincode

Hyperledger fabric chaincode upgrade


I have setup the hyper-ledger fabric network with 2 organisation, and have install the fabcar chain-code with version v1.1 on peer and i am keeping the storage of blockchain.

Next i added more methods on fabcar, Trying to upgrade the exist fabcar to v1.2, but i am facing the error.

Error: could not assemble transaction, err proposal response was not successful, error code 500, msg cannot get package for chaincode (fabcar:1.2)

I am using the below command to upgrade the chaincode

peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n fabcar -v 1.2 -c '{"Args":[""]}' -P "OR('Org1MSP.peer','Org2MSP.peer')"

Solution

  • Error: could not assemble transaction, err proposal response was not successful, error code 500, msg cannot get package for chaincode (fabcar:1.2)

    Means your upgraded chaincode was not installed on peers.

    Check Your chanincode installed on peers or not?

    peer chaincode list --installed
    

    In the output, You saw the only previous installed chaincode. So you have to first package a chaincode and then upgrade a chaincode.

     peer chaincode package ccpack.out -n fabcar -p github.com/hyperledger/fabric/examples/chaincode/go/fabcar -v 1.2 -s -S
    

    peer chaincode signpackage example

     peer chaincode signpackage ccwith1sig.pak ccwith2sig.pak
    

    Upgrade chaincode

    peer chaincode upgrade -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C mychannel -n fabcar -v 1.2 -c '{"Args":[""]}' -P "OR('Org1MSP.peer','Org2MSP.peer')"
    

    I recommend this link to upgrade your fabric chaincode.

    Note: replace chaincode path with your chaincode path.

    Hope it will help you :)