Search code examples
hyperledger-fabrichyperledgerhyperledger-chaincode

Hyperledger Fabric - cannot instantiate contract as per the MagnetoCorp example


Whenever I try to instantiate a contract according to the MagnetoCorp example, I receive the following errors. In the terminal:

2019-03-06 14:18:49.695 UTC [chaincodeCmd] InitCmdFactory -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2019-03-06 14:18:49.697 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default escc
2019-03-06 14:18:49.697 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg cannot get package for chaincode (papercontract:0)

And the monitordocker output:

peer0.org1.example.com|2019-03-06 14:26:51.556 UTC [endorser] callChaincode -> INFO 04e [][9f290f94] Entry chaincode: name:"cscc" 
peer0.org1.example.com|2019-03-06 14:26:51.557 UTC [endorser] callChaincode -> INFO 04f [][9f290f94] Exit chaincode: name:"cscc"  (1ms)
peer0.org1.example.com|2019-03-06 14:26:51.557 UTC [comm.grpc.server] 1 -> INFO 050 unary call completed {"grpc.start_time": "2019-03-06T14:26:51.555Z", "grpc.service": "protos.Endorser", "grpc.method": "ProcessProposal", "grpc.peer_address": "172.21.0.7:35966", "grpc.code": "OK", "grpc.call_duration": "1.572108ms"}
peer0.org1.example.com|2019-03-06 14:26:51.566 UTC [endorser] callChaincode -> INFO 051 [mychannel][ffd5a8c0] Entry chaincode: name:"lscc" 
peer0.org1.example.com|2019-03-06 14:26:51.566 UTC [lscc] executeDeployOrUpgrade -> ERRO 052 cannot get package for chaincode (papercontract:0)-err:open /var/hyperledger/production/chaincodes/papercontract.0: no such file or directory
peer0.org1.example.com|2019-03-06 14:26:51.566 UTC [endorser] callChaincode -> INFO 053 [mychannel][ffd5a8c0] Exit chaincode: name:"lscc"  (0ms)
peer0.org1.example.com|2019-03-06 14:26:51.566 UTC [endorser] ProcessProposal -> ERRO 054 [mychannel][ffd5a8c0] simulateProposal() resulted in chaincode name:"lscc"  response status 500 for txid: ffd5a8c09f7f5bc101b8caf0631a28ff222be0df90a94ac9c41b939dba7bd208
peer0.org1.example.com|2019-03-06 14:26:51.566 UTC [comm.grpc.server] 1 -> INFO 055 unary call completed {"grpc.start_time": "2019-03-06T14:26:51.565Z", "grpc.service": "protos.Endorser", "grpc.method": "ProcessProposal", "grpc.peer_address": "172.21.0.7:35966", "grpc.code": "OK", "grpc.call_duration": "988.672µs"}
orderer.example.com|2019-03-06 14:26:51.570 UTC [orderer.common.broadcast] Handle -> WARN 00f Error reading from 172.21.0.7:47540: rpc error: code = Canceled desc = context canceled
orderer.example.com|2019-03-06 14:26:51.570 UTC [comm.grpc.server] 1 -> INFO 010 streaming call completed {"grpc.start_time": "2019-03-06T14:26:51.566Z", "grpc.service": "orderer.AtomicBroadcast", "grpc.method": "Broadcast", "grpc.peer_address": "172.21.0.7:47540", "error": "rpc error: code = Canceled desc = context canceled", "grpc.code": "Canceled", "grpc.call_duration": "4.646613ms"}

The only line that makes sense to me is this:

executeDeployOrUpgrade -> ERRO 052 cannot get package for chaincode (papercontract:0)-err:open /var/hyperledger/production/chaincodes/papercontract.0: no such file or directory

because the /var/hyperledger directory does not exist in my system.


Solution

  • The /var/hyperledger/production/chaincodes folder is on the filesystem of the Peer container, not your local system.

    Assuming you are working with a local sample fabric, you can check the contents of the folder with a command similar to:

    docker exec -it peer0.org1.example.com ls /var/hyperledger/production/chaincodes

    This should show you the chaincodes that you have installed. Hopefully the output will show you the exact name and version you have installed and need to instantiate, but if not, you need to go back to the peer chaincode install command in the previous step.