Get Account Nonce
Returns the nonce of a given AvN account for different nonce types.
await api.query.getNonce(<acct>);
important
You can get the AVN_GATEWAY_URL here.
Possible Nonce Types
token
payment
staking
confirmation
- Example
- Example Result
- JSON-RPC
- JSON-RPC Output
const AVN_API = require("avn-api");
const AVN_GATEWAY_URL = "<node_url>";
const options = {
suri: "<account_suri>",
};
const API = new AVN_API(AVN_GATEWAY_URL, options);
const ACCOUNT = "5DAgx...";
const NONCE_TYPE = "payment"
async function main() {
await api.init();
//See other nonce type options below
let nonce = await api.query.getNonce(ACCOUNT, NONCE_TYPE);
console.log(nonce)
}
(async () => {
await main();
})();
3
REQUEST
POST https://AVN_GATEWAY_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.
- nonceType [required] - a string representing the nonce type.
JSON-RPC Example
curl https://AVN_GATEWAY_URL/query \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer <awtToken>" \
-d '{"jsonrpc":"2.0", "method":"getNonce", "params":{"accountId":"5GLV...DB9MH", "nonceType":"token"}, "id":1}'
note
result - string integer value of the current account nonce.
{
"jsonrpc": "2.0",
"id": 1,
"result": "3"
}