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