Installing a Chaincode
Function
This API is used to install a chaincode on blockchain nodes. In some scenarios, only Go chaincodes are supported.
URI
POST /v2/agent/apis/chaincode/install
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
chaincode_name |
Yes |
String |
Chaincode name, which must start with a letter and can contain lowercase letters and digits. 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. Minimum: 1 Maximum: 14 |
target_peers |
Yes |
String |
List of peers where the chaincode is installed, for example, [{"org_id":"9fb42c91458763990a45b62af92546a21f168dae","org_name":"organization3","peer_id":"peer-9fb42c91458763990a45b62af92546a21f168dae-0.peer-9fb42c91458763990a45b62af92546a21f168dae.default.svc.cluster.local","peer_name":"peer-0"}]. |
description |
No |
String |
Chaincode description. |
chaincode_language |
Yes |
String |
Programming language of the chaincode, for example, Go. |
db_type |
No |
String |
Database type used by the chaincode. Set this parameter based on the ledger data storage mode set during instance creation. Example: goleveldb or couchdb. |
security_check |
No |
String |
Chaincode security check option. This parameter is valid only for Golang chaincodes. The value true indicates that the function is enabled, and the value false indicates that the function is disabled. The default value is false. |
file |
Yes |
File |
Chaincode ZIP file. |
Response Parameters
Status code: 200
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
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_message |
String |
Error description. |
error_msg |
String |
Error description. |
Example Requests
POST https://192.168.0.90:30603/v2/agent/apis/chaincode/install {chaincode_name:gochaincode3chaincode_version:2.0target_peers:[{"org_id":"9802af57cfab764dc12b860c44b01969575e83c9","org_name":"organization","peer_id":"peer-9802af57cfab764dc12b860c44b01969575e83c9-1.peer-9802af57cfab764dc12b860c44b01969575e83c9.default.svc.cluster.local","peer_name":"node-1"}]description:22222222chaincode_language:golangdb_type:goleveldbsecurity_check:true}
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot