You can call this operation to create a chaincode.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateFabricChaincode | The operation that you want to perform. Set the value to CreateFabricChaincode. |
ChannelId | String | Yes | chan-first-channel-1w55v3u39x2xz | The ID of the channel. |
ConsortiumId | String | Yes | consortium-aaaaaa-akpcsjjac2jd | The ID of the consortium. |
OrganizationId | String | Yes | peers-aaaaaa1-1oxw31d046jtl | The ID of the organization. |
OssBucket | String | Yes | https://chaincode.oss-cn-beijing.aliyuncs.com | The IP address of the OSS bucket. |
OssUrl | String | Yes | aaaaaa1/a0cf8729-7d47-44c9-9ed5-6d2fdfc8dc2c/sacc.cc | The IP address of the OSS object. |
EndorsePolicy | String | No | OR ('aaaaaa1MSP.peer') | The endorsement policy. |
Location | String | No | cn-hangzhou | The location information. |
Response parameters
Parameter | Type | Example | Description |
ErrorCode | Integer | 200 | The error code. |
RequestId | String | CD264CC8-B892-4CDC-BD31-7D179EE6E396 | The ID of the API request. |
Result | The result. | ||
ChaincodeId | String | code-sacc-1pr09q7jmo0np | The ID of the chaincode. |
ChaincodeName | String | mychaincode | The name of the chaincode. |
ChaincodeVersion | String | 1.0 | The version of the chaincode. |
ChannelName | String | first-channel | The name of the channel. |
ConsortiumId | String | consortium-aaaaaa-akpcsjjac2jd | The ID of the consortium. |
CreateTime | String | 1544766801000 | The time when the chaincode was created. |
DeployTime | String | 1544766801000 | The time when the chaincode was deployed. |
EndorsePolicy | String | OR ('aaaaaa1MSP.peer') | The endorsement policy. |
Input | String | string | The input. |
Install | Boolean | true | Indicates whether the chaincode is installed. A value of true indicates that the chaincode is installed. A value of false indicates that the chaincode has not been installed. |
Message | String | string | The message. |
Path | String | go-sdk-demo/chaincode/src | The path. |
ProviderId | String | peers-aaaaaa1-1oxw31d046jtl | The ID of the chaincode uploader. |
ProviderName | String | peers-aaaaaa1-1oxw31d046jtl | The name of the chaincode uploader. |
State | String | Instantiatable | The status. |
Type | Integer | 1 | The type of the chaincode. |
Success | Boolean | true | Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call has failed. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateFabricChaincode
&OrganizationId=peers-aaaaaa1-1oxw31d046jtl
&ChannelId=chan-first-channel-1w55v3u39x2xz
&ConsortiumId=consortium-aaaaaa-akpcsjjac2jd
&OssBucket=https://chaincode.oss-cn-beijing.aliyuncs.com
&OssUrl=aaaaaa1/a0cf8729-7d47-44c9-9ed5-6d2fdfc8dc2c/sacc.cc
&EndorsePolicy=OR ('aaaaaa1MSP.peer')
&Location=cn-hangzhou
&<Common request parameters>Successful response examples
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateFabricChaincodeResponse>
<RequestId>CD264CC8-B892-4CDC-BD31-7D179EE6E396</RequestId>
<Success>true</Success>
<ErrorCode>200</ErrorCode>
<Result>
<Type>1</Type>
<EndorsePolicy>OR ('aaaaaa1MSP.peer')</EndorsePolicy>
<State>Instantiatable</State>
<CreateTime>1544766801000</CreateTime>
<ChaincodeId>code-sacc-1pr09q7jmo0np</ChaincodeId>
<ProviderName>peers-aaaaaa1-1oxw31d046jtl</ProviderName>
<Message>string</Message>
<ChaincodeName>mychaincode</ChaincodeName>
<Input>string</Input>
<Install>true</Install>
<ProviderId>peers-aaaaaa1-1oxw31d046jtl</ProviderId>
<DeployTime>1544766801000</DeployTime>
<ChaincodeVersion>1.0</ChaincodeVersion>
<ConsortiumId>consortium-aaaaaa-akpcsjjac2jd</ConsortiumId>
<ChannelName>first-channel</ChannelName>
<Path>go-sdk-demo/chaincode/src</Path>
</Result>
</CreateFabricChaincodeResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "CD264CC8-B892-4CDC-BD31-7D179EE6E396",
"Success" : true,
"ErrorCode" : 200,
"Result" : {
"Type" : 1,
"EndorsePolicy" : "OR ('aaaaaa1MSP.peer')",
"State" : "Instantiatable",
"CreateTime" : "1544766801000",
"ChaincodeId" : "code-sacc-1pr09q7jmo0np",
"ProviderName" : "peers-aaaaaa1-1oxw31d046jtl",
"Message" : "string",
"ChaincodeName" : "mychaincode",
"Input" : "string",
"Install" : true,
"ProviderId" : "peers-aaaaaa1-1oxw31d046jtl",
"DeployTime" : "1544766801000",
"ChaincodeVersion" : "1.0",
"ConsortiumId" : "consortium-aaaaaa-akpcsjjac2jd",
"ChannelName" : "first-channel",
"Path" : "go-sdk-demo/chaincode/src"
}
}Error codes
HttpCode | Error code | Error message | Description |
400 | ChaincodeDuplicated | The chaincode [%s] of version [%s] already exists. Change the name or the version of the chaincode. | The error message will be returned when the chaincode [%s] of version [%s] already exists. Change the name or the version of the chaincode. |
400 | ChaincodeInvalid | The format of the chaincode package is invalid. | The error message will be returned when the format of the chaincode is invalid. |
For more information about error codes, see Error codes.