2016-08-20 04:31
浏览 124

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题