Skip to main content
Version: 0.5

Querying a transaction

To query a transaction, you would need the request id returned after submitting your transaction to the AVN.

await api.poll.requestState(requestId);

RESULT FIELDS
The resulting state could be any of the following:

  • Pending
  • Pending and Lost
  • Processed
  • Errored
  • Unknown

Example

const AvnApi = require("avn-api");
const GATEWAY = "<endpoint_url>"; //Replace the endpoint_url with the url received from Aventus.
const api = new AvnApi(GATEWAY);

async function main() {
await api.init();

// Get the current state of a previously sent transaction.:
const state = await api.poll.requestState(requestId);
}

(async () => {
await main();
})();

Example Output

"Processed"

JSON-RPC

Gets the current state of a previously sent asynchronous transaction request

REQUEST POST https://AVN-API-URL/poll

HEADERS Content-Type: application/json Authorization': bearer <awtToken>

REQUEST PARAMS requestId [required] - string representing the request ID.

Example

curl https://AVN-API-URL/poll \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"requestState", "params":{"requestId":"410fe1c5-5deb-4a52-b89d-8bc9fc682415"}, "id":1}'

Example Result

{
"jsonrpc": "2.0",
"id": 1,
"result": "Processed"
}