douwei1408 2016-08-20 04:31
浏览 129
已采纳

HyperLedger-Fabric ChainCode部署-Base64错误

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

  • 写回答

1条回答 默认 最新

  • doupi6737 2016-08-20 08:11
    关注

    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']}

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装