我试图通过遵循Windows设置在我的笔记本电脑上设置Hyperledger blocchain,能够启动并运行docker镜像,但是当我尝试部署提供的示例时,它总是会抛出JSON中的错误输入如下所示。
<md-tabs md-selected="selectedIndex">
...
响应:
peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
我在主机上尝试了POSTMAN:
sug@sri-ub:~/go/$ docker exec -it aa413f4c4289 bash
root@aa413f4c4289:/opt/gopath/src/github.com/hyperledger/fabric# peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
04:30:55.822 [logging] LoggingInit -> DEBU 001 Setting default logging level to DEBUG for command 'chaincode' Error: Non-empty JSON chaincode parameters must contain exactly 1 key: 'Args'
获得了回复
{"jsonrpc":"2.0","method":"deploy","params":{"type":1,"chaincodeID":{"path":"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"},"ctorMsg":{"function":"init","args":["a", "1000", "b", "2000"]}},"id":1}
这与错误消息类似,我无法解决此问题,按照建议创建新帖子,请帮我解决此问题。
答案 0 :(得分:2)
在最新的Fabric版本中,请求的格式已更改。函数名称应为Args,所有参数均应为base64编码 而不是:
{"function":"init","args":["a", "1000", "b", "2000"]}}
deploy命令的参数如下所示:
{"args":['aW5pdA==', 'YQ==', 'MTAwMA==', 'Yg==', 'MjAwMA==']}
更新:格式再次更改。不再需要Base64编码。最新Fabric中的正确有效负载是:
{“args”:['init', 'a', '100', 'b', '100']}