The transaction will be sent to the blockchain network, and return success until the transaction is written into the ledger and passed the node verification.
API
POST /api/v1/networks/{network}/transactions/invoke
Url Path Args | Description |
---|---|
network | Fabric channel name |
Request Parameter
URL Query
URL Query Args | Type | Required | Description |
---|---|---|---|
timeout | Integer | False | Maximum wait time in seconds to confirm whether submitted transaction is success(valid) or not. Default is 180. |
content_check | String | False | Use Alibaba Cloud Content Moderation to check content. Config which suggestion(“pass”, “block”, “review”) should reject, multi-value split by comma(,). Default is “”, means don’t use Content Moderation. |
Body
Content-Type: application/json
Name | Type | Required | Description |
---|---|---|---|
chaincode | String | True | The Name of target smart contract |
args | List<String> | False | The arguments list of the smart contract call. When this parameter(args) is not empty, the function and byte_args parameters are ignored. |
function | String | False | The name of smart contract function to call |
byte_args | List<String> | False | Base64-encoded smart contract call arguments (without function name) |
transient | Map<String, String> | False | The transient map of this call, Key is the name, and Value is data |
byte_transient | Map<String, String> | False | The transient map of this call, Key is the name, and Value is base64-encoded data(this parameter will merge with transient and overrides the Key in it) |
invoke_chain | List<ChaincodeCall> | False | Provide smart contract name and private data collection list(if any) that will be used by target smart contract. This parameter is required if the target smart contract needs to invoke another smart contract. The parameter will be used for discovery and making transactions satisfy the endorsement policy. |
ChaincodeCall
Name | Type | Required | Description |
---|---|---|---|
chaincode | String | True | The name of smart contract |
collections | List<String> | False | The list of collections name that smart contract accessed. |
Response
Name | Type | Description |
---|---|---|
Success | Boolean | Indicating if the request was successful. |
Error | Error | - |
Result | Response | - |
Error
Name | Type | Description |
---|---|---|
code | Integer | Error code |
message | String | Error description |
request_id | String | The id of this request |
Response
Name | Type | Description |
---|---|---|
id | String | Transaction ID |
status | String | Status code returned by smart contract |
event | List<Event> | List of blockchain events generated by the transaction |
data | String | Base64-encoded data returned by smart contract |
Event
Name | Type | Description |
---|---|---|
id | String | Event ID, unique within the channel |
name | String | Event name |
type | EventType | Event type(“Tx”, “Config”, “Contract”, “Block”), here is always “Contract” |
content | String | When EventType is “Contract”, it is Base64 encoded event content |
Examples
Request Example
curl -X POST "http://your.gateway.endpoint/api/v1/networks/channel3/transactions/invoke" -H "accept: application/json" -H "Authorization: Bearer <Your Access Token>" -H "Content-Type: application/json" -d "{\"chaincode\":\"sacc\",\"args\":[\"set\",\"provider\",\"aliyun\"],\"transients\":{\"key\":\"value\"}}"
Example of Normal Return
{
"Success": true,
"Result": {
"id": "1bdbc050691cdf7c03faca74ebfa5711b18fb8acc23cabbd16a1a692d00785a1",
"status": "200",
"events": [],
"data": "YWxpeXVu"
},
"Error": {
"code": 200,
"message": "Success",
"request_id": "5945a095-5730-4f63-9ef9-ddbcb2cda8c8"
}
}
Error Code
Please refer to Error Code