Get Account Nonce
Returns the nonce of a given AvN account for different nonce types.
await API.query.getNonce(<acct>);
Example
const AVN_API = require("avn-api");
//Replace the endpoint_url with the url received from Aventus.
const AVN_GATEWAY_URL = "<endpoint_url>";
const API = new AVN_API(AVN_GATEWAY_URL);
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();
})();
Example Result
3
Possible Nonce Options
token
payment
staking
confirmation
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
- nonceType [required] - a string representing the nonce type.
JSON-RPC Example
curl https://AVN-API-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.
Example Output
{
"jsonrpc": "2.0",
"id": 1,
"result": "3"
}