Submits a transaction to the blockchain network and returns a result after the transaction is written to the ledger and passes node validation.
Request syntax
POST /api/v1/networks/{network}/transactions/invokePath parameters
| Parameter | Description |
|---|---|
network | The Fabric channel name. |
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
timeout | Integer | No | The maximum wait time in seconds to confirm whether the submitted transaction succeeded. Default value: 180. |
content_check | String | No | The Content Moderation check configuration. Specifies which moderation suggestion (pass, block, or review) causes the request to be rejected. Separate multiple values with commas (,). Default value: "" (Content Moderation is disabled). |
Request body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
chaincode | String | Yes | The name of the target smart contract (chaincode). |
args | List\<String\> | No | The arguments for the smart contract call. When args is specified, the function and byte_args parameters are ignored. |
function | String | No | The name of the smart contract function to call. |
byte_args | List\<String\> | No | The Base64-encoded arguments for the smart contract call, excluding the function name. |
transient | Map\<String, String\> | No | The transient map for this call. Keys are names; values are data. |
byte_transient | Map\<String, String\> | No | The transient map for this call, where values are Base64-encoded. Merged with transient; keys in byte_transient override matching keys in transient. |
invoke_chain | List\<ChaincodeCall\> | No | The list of smart contracts and their private data collections invoked by the target smart contract. Required when the target smart contract invokes another smart contract. Used for discovery and ensuring transactions satisfy the endorsement policy. |
ChaincodeCall object
| Parameter | Type | Required | Description |
|---|---|---|---|
chaincode | String | Yes | The name of the smart contract. |
collections | List\<String\> | No | The names of the private data collections accessed by the smart contract. |
Response elements
| Field | Type | Description |
|---|---|---|
Success | Boolean | Indicates whether the request succeeded. |
Error | Error | The error details. |
Result | Response | The transaction result. |
Error object
| Field | Type | Description |
|---|---|---|
code | Integer | The error code. |
message | String | The error message. |
request_id | String | The request ID. |
Result object
| Field | Type | Description |
|---|---|---|
id | String | The transaction ID. |
status | String | The status code returned by the smart contract. |
event | List\<Event\> | The list of blockchain events generated by the transaction. |
data | String | The Base64-encoded data returned by the smart contract. |
Event object
| Field | Type | Description |
|---|---|---|
id | String | The event ID, unique within the channel. |
name | String | The event name. |
type | EventType | The event type. Valid values: Tx, Config, Contract, Block. For transaction invocations, this is always Contract. |
content | String | The event content. When type is Contract, the content is Base64-encoded. |
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"}}'Response example
{
"Success": true,
"Result": {
"id": "1bdbc050691cdf7c03faca74ebfa5711b18fb8acc23cabbd16a1a692d00785a1",
"status": "200",
"events": [],
"data": "YWxpeXVu"
},
"Error": {
"code": 200,
"message": "Success",
"request_id": "5945a095-5730-4f63-9ef9-ddbcb2cda8c8"
}
}Error codes
For a list of error codes, see Error codes.