Send a Transaction

post

/restproxy/api/v2/channels/{channelId}/transactions

Send a transaction

Request

Supported Media Types
Path Parameters
Body ()
Request to invoke a transaction
Root Schema : schema
Type: object
Show Source
Nested Schema : args
Type: array
Arguments for the chaincode
Show Source
Nested Schema : endorsers
Type: array
Endorsers for the chaincode
Show Source
Nested Schema : transientMap
Type: object
Additional Properties Allowed
Show Source
TransientMap for the chaincode
Back to Top

Response

Supported Media Types

201 Response

Operation successful for synchronous transaction
Body ()
Root Schema : schema
Type: object
Show Source
Nested Schema : result
Type: object
Show Source

202 Response

Operation successful for asynchronous transaction
Body ()
Root Schema : schema
Type: object
Show Source
Nested Schema : result
Type: object
Show Source

400 Response

Bad Request

401 Response

Not authorized

403 Response

Forbidden

404 Response

Invalid parameters

500 Response

Service unavailable
Back to Top

Examples

This endpoint is used to invoke an asynchronous transaction providing a new transaction ID and nonce.

Note:

Before invoking this endpoint, you must generate a new asynchronous transaction ID and nonce using the Get a New Transaction ID and Nonce endpoint.

The following example shows how to invoke an asynchronous transaction by submitting a POST request on the REST resource using cURL.

curl -v -u <username>:<password> -X POST \
  "https://<rest proxy of your blockchain instance>/api/v2/channels/default/transactions" \
  -H "accept: application/json" \
  -H "Content-Type: application/json" \
  --data @<JSON file with the request parameters>

For example,

curl -v -u <username>:<password> -X POST \
  "https://myvm.oracle.com:10001/restproxy/api/v2/channels/default/transactions" \
  -H "accept: application/json" \
  -H "Content-Type: application/json" 
  --data @file.json
The contents of file.json are:
{
 "txid": "bb248ef3f948cb107417c3f66ea144910644dee8086a370d44687fd9fe262233",
 "nonce": "b508e30891a738162a35ebd1b7f768f8e8520111e4201dd9",
 "chaincode": "obcs-example02",
 "args": [ "invoke","a","b","200" ],
 "timeout": 18000,
 "sync": false
}
Where:
  • txid and nonce are the values generated using the Get a New Transaction ID and Nonce endpoint.
  • chaincode is the chaincode ID of the Balance Transfer sample chaincode.
  • args specify the chaincode function to be invoked along with it's parameters.
  • timeout specifies the maximum number of milliseconds for the transaction to timeout.
  • sync with a false value indicates that this is not a synchronous transaction.

Note:

You can find the restproxy value of your Blockchain instance from the Nodes tab of your instance console.

Example of the Response Body

The following example shows the contents of the response body in JSON format:

{
    "returnCode": "Success",
    "error": "",
    "result": {
        "txid": "bb248ef3f948cb107417c3f66ea144910644dee8086a370d44687fd9fe262233",
        "payload": null,
        "encode": ""
    }
}

In this case, the value returned for payload is null because the chaincode function invoked was not a chaincode query and therefore, it did not return any value.

Back to Top