Skip to content

How to Deploy a Sample Contract

Igor Ramos edited this page Apr 4, 2017 · 3 revisions

How to Deploy a Sample Contract

Here's an example on how to deploy the trade lane sample contract to your IBM Blockchain instance in Bluemix:

Send a POST request to your peer with the payload below.

Example: POST http://ABCD_vp1-api.blockchain.ibm.com:80/chaincode

Payload:

{
    "jsonrpc": "2.0",
    "method": "deploy",
    "params": {
        "type": 1,
        "chaincodeID":{
              "path": "https://github.com/ibm-watson-iot/blockchain-samples/contracts/advanced/iot_sample_contract.0.6"
        },
        "ctorMsg": {
            "function":"init",
            "args":["{\"version\":\"1.0\",\"nickname\":\"iot_sample_contract.0.6\"}"]
        },
        "secureContext": "dashboarduser_type0_0000011111"
    },
    "id":1234
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "status": "OK",
    "message": "760e65787b39fb95866437943d264da8c7f730c2355cbbd9dd4eec8c59ea089dcada97c06cc01876507e7b02d247a2f1989c9e84dbfb065fb3b376514b770012"
  },
  "id": 1234
}

Example in cURL

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{
    "jsonrpc": "2.0",
    "method": "deploy",
    "params": {
        "type": 1,
        "chaincodeID":{
              "path": "https://github.com/ibm-watson-iot/blockchain-samples/contracts/advanced/iot_sample_contract.0.6"
        },
        "ctorMsg": {
            "function":"init",
            "args":["{\"version\":\"1.0\",\"nickname\":\"iot_sample_contract.0.6\"}"]
        },
        "secureContext": "dashboarduser_type0_0000011111"
    },
    "id":1234
}' "http://ABCD_vp1-api.blockchain.ibm.com:80/chaincode"
Clone this wiki locally