“Error getting chaincode package bytes” when deplo

2019-02-19 11:12发布

问题:

I'm trying to deploy chaincode on hyperledger (Bluemix service) via POST/REST to

/chaincode QuerySpec

{ "jsonrpc": "2.0", "method": "deploy", "params": { "type": 1, "chaincodeID": { "path": "https://github.com/romeokienzler/learn-chaincode/tree/master/finished" }, "ctorMsg": { "function": "init", "args": [ "hi there" ] }, "secureContext": "user_type1_0" }, "id": 1 }

I've also tried those links

https://github.com/romeokienzler/learn-chaincode/blob/master/finished/chaincode_finished?raw=true

https://raw.githubusercontent.com/romeokienzler/learn-chaincode/master/finished/chaincode_finished.go

I always get

{ "jsonrpc": "2.0", "error": { "code": -32001, "message": "Deployment failure", "data": "Error when deploying chaincode: Error getting chaincode package bytes: Error getting code 'go get' failed with error: 'exit status 1'\npackage github.com/romeokienzler/learn-chaincode/tree/master/finished: cannot find package 'github.com/romeokienzler/learn-chaincode/tree/master/finished' in any of:\n\t/usr/local/go/src/github.com/romeokienzler/learn-chaincode/tree/master/finished (from $GOROOT)\n\t/go/usercode/552962906/src/github.com/romeokienzler/learn-chaincode/tree/master/finished (from $GOPATH)\n\t/go/src/github.com/romeokienzler/learn-chaincode/tree/master/finished\n" }, "id": 1 }

Any idea?

回答1:

Considering that you are playing with Bluemix service, I assume you are following "Implementing your first chain code tutorial"

If your forked repository you will see instructions to use branch v1.0 for Bluemix Blockchain Services (link) IBM BMX Service is (still) using Fabric v0.5.

Once you have Registered with one of the available Enroll ID you should be able to deploy your chaincode using DeploySpec (note the path: "https://github.com/romeokienzler/learn-chaincode/tree/v1.0/finished")

{
"jsonrpc": "2.0",
  "method": "deploy",
  "params": {
    "type": 1,
    "chaincodeID": {
      "path": "https://github.com/romeokienzler/learn-chaincode/tree/v1.0/finished"
    },
    "ctorMsg": {
      "function": "init",
      "args": [
        "hi there"
      ]
    },
    "secureContext": "user_type1_0"
  },
  "id": 1
}


回答2:

First of all deploy command should be changed to ( the value for path variable was changed):

{
    "jsonrpc": "2.0",
    "method": "deploy",
    "params": {
        "type": 1,
        "chaincodeID": {
            "path": "https://github.com/romeokienzler/learn-chaincode/finished"
        },
        "ctorMsg": {
            "function": "init",
            "args": ["hi there"]
        },
        "secureContext": "user_type1_0"
    },
    "id": 1
}

P.S. As @Mil4n correctly mentioned, IBM Bluemix still works with Fabric v0.5. Chaincode romeokienzler/learn-chaincode/finished should be adopted to this version.

For example shim.ChaincodeStubInterface is not available yet and should be replaced with *shim.ChaincodeStub.