HyperLedger-Fabric ChainCode 部署 - Base64 错误
HyperLedger-Fabric ChainCode Deployment - Base64 error
我试图按照 Windows 设置在我的笔记本电脑上设置 Hyperledger 区块链,能够调出 docker 图像和 运行,但是当我尝试部署提供的示例,它总是在 JSON 输入中返回错误,如下所示。
peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
回复:
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'
我在 HOST 机器的 POSTMAN 中试过:
{"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}
收到的回复为
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Error unmarshalling chaincode request payload: illegal base64 data at input byte 0"},"
这与错误消息类似,我仍然无法解决这个问题,按照建议创建一个新的 post,请帮我解决这个问题。
Similar issue reported but that also doesn't answer
在最新的结构版本中,请求的格式已更改。函数名称应在 Args 中,所有参数应采用 base64 编码。
而不是:
{"function":"init","args":["a", "1000", "b", "2000"]}}
部署命令的参数如下所示:
{"args":['aW5pdA==', 'YQ==', 'MTAwMA==', 'Yg==', 'MjAwMA==']}
更新: 格式又改了。不再需要 Base64 编码。最新 Fabric 中的正确负载是:
{“args”:['init', 'a', '100', 'b', '100']}
我试图按照 Windows 设置在我的笔记本电脑上设置 Hyperledger 区块链,能够调出 docker 图像和 运行,但是当我尝试部署提供的示例,它总是在 JSON 输入中返回错误,如下所示。
peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
回复:
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'
我在 HOST 机器的 POSTMAN 中试过:
{"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}
收到的回复为
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Error unmarshalling chaincode request payload: illegal base64 data at input byte 0"},"
这与错误消息类似,我仍然无法解决这个问题,按照建议创建一个新的 post,请帮我解决这个问题。
Similar issue reported but that also doesn't answer
在最新的结构版本中,请求的格式已更改。函数名称应在 Args 中,所有参数应采用 base64 编码。
而不是:
{"function":"init","args":["a", "1000", "b", "2000"]}}
部署命令的参数如下所示:
{"args":['aW5pdA==', 'YQ==', 'MTAwMA==', 'Yg==', 'MjAwMA==']}
更新: 格式又改了。不再需要 Base64 编码。最新 Fabric 中的正确负载是:
{“args”:['init', 'a', '100', 'b', '100']}