Updated on 2023-10-09 GMT+08:00

Deleting a Chaincode

Function

This API is used to delete a chaincode from blockchain nodes.

URI

DELETE /v2/agent/apis/chaincode/uninstall

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

chaincode_name

Yes

String

Chaincode name, which can contain 6 to 25 lowercase letters and digits and must start with a letter.

Minimum: 6

Maximum: 25

chaincode_version

Yes

String

Chaincode version. Only digits, periods (.), and hyphens (-) are allowed. The value must start and end with a digit, and the periods (.) and hyphens (-) cannot be adjacent.

target_peers

Yes

Array of TargetPeer objects

Details of peers where the chaincode is uninstalled.

Table 3 TargetPeer

Parameter

Mandatory

Type

Description

org_id

Yes

String

ID of the organization to which the peer belongs.

peer_id

Yes

String

Peer ID

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

total_peer_num

Integer

Total number of peers where the chaincode is installed.

success_peer_num

Integer

Number of peers where the chaincode is installed successfully.

fail_peer_num

Integer

Number of peers where the chaincode fails to be installed.

fail_peers

Array of strings

Details of peers where the chaincode fails to be installed.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_message

String

Error description.

error_msg

String

Error description.

Example Requests

DELETE https://192.168.0.90:30603/v2/agent/apis/chaincode/uninstall

{
  "chaincode_name" : "chaincode1",
  "chaincode_version" : "1.0",
  "target_peers" : [ {
    "org_id" : "9802af57cfab764dc12b860c44b01969575e83c9",
    "peer_id" : "peer-9802af57cfab764dc12b860c44b01969575e83c9-1.peer-9802af57cfab764dc12b860c44b01969575e83c9.default.svc.cluster.local"
  } ]
}

Example Responses

Status code: 200

Success

{
  "total_peer_num" : 4,
  "success_peer_num" : 4,
  "fail_peer_num" : 0,
  "fail_peers" : [ ]
}

Status code: 400

Bad Request

{
  "error_code" : "BCS.4000013",
  "error_message" : "request body is too large"
}

Status Codes

Status Code

Description

200

Success

400

Bad Request

Error Codes

See Error Codes.