Working with QEDIT Tasks

Some API calls take time to complete. In particular any call that requires writing a new block in the Blockchain (e.g. transferring an asset) will take time to complete. As such many of the QEDIT API endpoints are asynchronous. when called, these endpoints return a task ID. The API user can then query the status of this task ID to determine whether and when it was completed successfully.

Getting the status of a task

To check the status of a specific task use the following endpoint

Request

POST /node/get_task_status
{
  "id": "5aaa4045-e949-4c44-a7ef-25fb55a1afa6"
}

Response

{
  "id": "5aaa4045-e949-4c44-a7ef-25fb55a1afa6",
  "created_at": "2019-08-11T10:37:04Z",
  "updated_at": "2019-08-12T11:12:59Z",
  "result": "in_progress",
  "state": "tx_submitted",
  "tx_hash": "0xd379aa4e5e40552910c8ae456c65dcf51e9779fc9281ac2dc9e677ec810af6b1",
  "type": "transfer_asset",
  "data": {}
}

Listing the tasks in a QEDIT node

The QEDIT API allows you to list all the tasks in a QEDIT node. You filter the results to certain types of task (e.g. “transfer_asset”) or certain result statuses (e.g. “in_progress”)

Request

POST /node/get_tasks
{
  "start_index": 0,
  "number_of_results": 1,
  "types": [
    "unlock_wallet",
    "transfer_asset"
  ],
  "results": [
    "in_progress",
    "failure"
  ],
  "order": "asc"
}

Response

{
  "tasks": [
    {
      "id": "5aaa4045-e949-4c44-a7ef-25fb55a1afa6",
      "created_at": "2019-08-11T10:37:04Z",
      "updated_at": "2019-08-12T11:12:59Z",
      "result": "in_progress",
      "state": "tx_submitted",
      "tx_hash": "0xd379aa4e5e40552910c8ae456c65dcf51e9779fc9281ac2dc9e677ec810af6b1",
      "type": "transfer_asset",
      "data": {}
    }
  ]
}

Approving a task

Some tasks require user interaction. For example, if an asset transfer addressed to one of the wallets in a node requires confirmation it will appear as a task in the /node/get_tasks endpoint. At that point the API user will need to approve the task in order to complete the transfer (or to cancel it as described later in this section).

Request

POST /node/approve_task
{
  "task_id": "5aaa4045-e949-4c44-a7ef-25fb55a1afa6",
  "authorization": "PrivacyIsAwesome"
}

Response

Cancelling a task

Some tasks can be cancelled before they are finalized. For example, if an asset transfer addressed to one of the wallets in a node requires confirmation it will appear as a task in the /node/get_tasks endpoint. At that point the API user can reject the transfer by cancelling the task.

Request

POST /node/cancel_task
{
  "task_id": "5aaa4045-e949-4c44-a7ef-25fb55a1afa6",
  "authorization": "PrivacyIsAwesome"
}

Response