问题
I have setup a peer in a vm and its running fine. Also i have registered the chaincode with the peer through this
CORE_CHAINCODE_ID_NAME=chaincode_example02 CORE_PEER_ADDRESS=localhost:51011 ./chaincode_example02
and it showed no error
Now after this when i try to hit the init method from rest using this json
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID":{
"name": "chaincode_example02",
"path": "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
},
"ctorMsg": {
"function":"init",
"args": ["a","100","b","200"]
}
},
"id": 10
}
i get this error
{
"jsonrpc": "2.0"
"error": {
"code": -32700
"message": "Parse error"
"data": "Error unmarshalling chaincode request payload: illegal base64 data at input byte 0"
}-
"id": null
}
Can anybody tell me what am i doing wrong?
回答1:
I got the same error. Following is what I've done and returned message. Please find my traffic log captured by tcpdump in the attached screenshot. Looks like nothing has been actually transferred except for controlling signals
I started a validating peer running noops consensus with this command in 1st terminal console
docker run --name vp0 --rm -it -e CORE_VM_ENDPOINT=unix:///var/run/docker.sock -p 7050:7050 -p 7051:7051 -p 7054:7054 -p 7053:7053 -e CORE_LOGGING_LEVEL=DEBUG -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger/fabric-peer peer node start
I register the example chaincode with these commands in 2nd terminal console
cd $GOPATH/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
go build
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7051 ./chaincode_example02
the 1st terminal console show that my example chaincode got registered
18:32:12.070 [chaincode] HandleChaincodeStream -> DEBU 061 Current context deadline = 0001-01-01 00:00:00 +0000 UTC, ok = false
18:32:12.071 [chaincode] processStream -> DEBU 062 []Received message REGISTER from shim
18:32:12.071 [chaincode] HandleMessage -> DEBU 063 []Handling ChaincodeMessage of type: REGISTER in state created
18:32:12.071 [chaincode] beforeRegisterEvent -> DEBU 064 Received REGISTER in state created
18:32:12.071 [chaincode] registerHandler -> DEBU 065 registered handler complete for chaincode mycc
18:32:12.071 [chaincode] beforeRegisterEvent -> DEBU 066 Got REGISTER for chaincodeID = name:"mycc" , sending back REGISTERED
18:32:12.071 [chaincode] notifyDuringStartup -> DEBU 067 nothing to notify (dev mode ?)
the 2nd terminal console says everything seems to be fine
18:32:12.069 [shim] DEBU : Peer address: 0.0.0.0:7051
18:32:12.070 [shim] DEBU : os.Args returns: [./chaincode_example02]
18:32:12.070 [shim] DEBU : Registering.. sending REGISTER
18:32:12.071 [shim] DEBU : []Received message REGISTERED from shim
18:32:12.071 [shim] DEBU : []Handling ChaincodeMessage of type: REGISTERED(state:created)
18:32:12.071 [shim] DEBU : Received REGISTERED, ready for invocations
When I deploy the example chaincode to the peer, I got the error message
peer chaincode deploy -n mycc -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
19:03:33.715 [logging] LoggingInit -> DEBU 001 Setting default logging level to DEBUG for command 'chaincode' Error: Chaincode argument error: illegal base64 data at input byte 0
来源:https://stackoverflow.com/questions/38918739/hyperledger-fabric-chaincode-deployment-giving-parse-error