Skip to main content
Version: 0.5

Get Account Nonce

Returns the nonce of a given AvN account.

//replace with the specific account
await api.query.getAccountNonce(<account>);

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();

// Return the nonce of a specific account:
let acctNonce = await api.query.getAccountNonce(<account>);
console.log(acctNonce)
//"3"
}

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

Example Output

321

JSON-RPC

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

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

REQUEST PARAMS accountId [required] - a string representing the public key or SS58 address of the account to check for nonce

EXAMPLE

## JSON-RPC over HTTPS POST
curl https://AVN-API-URL/query \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"getAccountNonce", "params":{"accountId":"5GLVUNb9oKLesAjDt17X1N49xyp2fr62sKPAKLgmmNbDB9MH"}, "id":1}'

RESULT FIELDS VALUE - string integer value of the current account nonce

BODY

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