2016-08-20 04:31 阅读 109

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 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'


sug@sri-ub:~/go/$ docker exec -it aa413f4c4289 bash
root@aa413f4c4289:/opt/gopath/src/ peer chaincode deploy -p -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":""},"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 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']}

    点赞 评论 复制链接分享