本文介绍了HyperLedger-Fabric ChainCode部署 - Base64错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过遵循Windows安装程序在我的笔记本电脑上设置Hyperledger blocchain,能够启动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 - ['a','100','b','200']}'

04:30:55.822 LoggingInit - > DEBU 001将默认日志记录级别设置为DEBUG以获得命令'chaincode'错误:非空的JSON链接代码参数必须包含1个键:'参数'

我在HOST机器的POSTMAN中尝试过:

  {jsonrpc:2.0 方法: 部署, PARAMS:{ 类型:1, chaincodeID:{ 路径: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:解编码链接请求有效载荷时出错:输入字节0的非法base64数据}, 

这与错误消息类似,我仍然无法解决这个问题,建议,请帮我解决这个问题。



结构的版本请求的格式已更改。函数名应该在Args中,并且所有参数都应该是base64编码。

而不是:
$ b $ p $ {function: init,args:[a,1000,b,2000]}}



部署命令的参数将如下所示:



{args:['aW5pdA ==','YQ ==','MTAwMA = =','Yg ==','MjAwMA ==']}


$ b 更新:格式已更改再次。 Base64编码不再需要。在最新Fabric中正确的有效载荷为:

{args:['init','a','100','b', '100']}


I was trying to setup the Hyperledger blocchain on my laptop by following the Windows setup , was able to bring the docker images up and running, but when I try to deploy the examples provided, it always throws back the error in the JSON input as shown below.

peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

response:

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'

I tried in POSTMAN from the HOST machine:

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

got the response as

{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Error unmarshalling chaincode request payload: illegal base64 data at input byte 0"},"

This is similar to the error message and I couldn't resolve this still, creating a new post as advised, please help me fix this issue.

Similar issue reported but that also doesn't answer

解决方案

In latest fabric's version the request's format was changed. Function name should be in Args and all parameters should be base64 encoded.
Instead of:

{"function":"init","args":["a", "1000", "b", "2000"]}}

The arguments for deploy command will look like:

{"args":['aW5pdA==', 'YQ==', 'MTAwMA==', 'Yg==', 'MjAwMA==']}

Update: Format was changed again. Base64 encoding is not necessary any longer. correct payload in latest Fabric is:

{"args":['init', 'a', '100', 'b', '100']}

这篇关于HyperLedger-Fabric ChainCode部署 - Base64错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:54