Channel code

1. Package

POST api/v1/chaincodes/package

The chain code needs to be packaged before being installed on the peer node

Body ParametersTypeNote
namestring
versionstring
languagestring
md5string
fileFile

Example Request

 

Example Response

{
    "data": null,
    "msg": "package chaincode failed.",
    "status": "fail"
}

2. Install

POST api/v1/chaincodes/install

Install chaincode to the peer nodes.

Body ParametersTypeNote
idUUID

Example Request Body:

 

Example Response Body:

{
    		"data": "success",
    		"msg": null,
   		"status": "successful"
}

3. Query Installed chaincodes

GET api/v1/chaincodes/query_installed

Query installed chaincodes in the peer nodes.

Example Response Body:

{
    "data": {
        "installed_chaincodes": [
            {
                "package_id": "mycc_v1:93ac5ffaf361bafb9b7738d6094edb7e0e6f64b1a4414bd5d84436686422c0ac",
                "label": "mycc_v1"
            }
        ]
    },
    "msg": null,
    "status": "successful"
}

4. Get installed package

GET api/v1/chaincodes/get_installed_package

Get the installed chaincode in peer nodes and store them in dir /opt/node.

Example Response Body

{
    "data": "success",
    "msg": null,
    "status": "successful"
}

5. Approve Chaincode

POST api/v1/chaincodes/approve_for_my_org

Approve chaincode by calling lifecycle_approve_for_my_org interface of peer binary file.


Body ParametersTypeNote
channel_namestring
chaincode_namestring
chaincode_versionstring
policystring
orderer_urlstring
sequeence int

Example Response Body

{
    "data": "success",
    "msg": null,
    "status": "successful"
}

6. Query Approved Chaincode

GET api/v1/chaincodes/query_approved

Query approved chaincode information

Body ParameterTypeNote
channel_namestring
chaincode_namestring

Example Response Body:

{
    "data": {
        "sequence": 1,
        "version": "v2",
        "endorsement_plugin": "escc",
        "validation_plugin": "vscc",
        "validation_parameter": "ChcSCBIGCAESAggAGgsSCQoHT3JnMU1TUA==",
        "collections": {},
        "init_required": true,
        "source": {
            "Type": {
                "LocalPackage": {
                    "package_id": "mycc_v2:93ac5ffaf361bafb9b7738d6094edb7e0e6f64b1a4414bd5d84436686422c0ac"
                }
            }
        }
    },
    "msg": null,
    "status": "successful"
}

7. List chaincodes

GET api/v1/chaincodes

List chaincode that user-owned