Hyperledger Fabric - 无法根据 MagnetoCorp 示例实例化合同

Hyperledger Fabric - cannot instantiate contract as per the MagnetoCorp example

每当我尝试根据 MagnetoCorp example 实例化合约时,我都会收到以下错误。 在终端中:

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)

并且 monitordocker 输出:

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"}

唯一对我有意义的行是:

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

因为 /var/hyperledger 目录在我的系统中不存在。

/var/hyperledger/production/chaincodes 文件夹在对等容器的文件系统上,不是您的本地系统。

假设您正在使用本地示例结构,您可以使用类似于以下的命令检查文件夹的内容:

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

这应该会显示您已安装的链代码。希望输出会向您显示您已安装并需要实例化的确切名称和版本,但如果没有,您需要返回到上一步中的 peer chaincode install 命令。