Get Account Nonce
Returns the nonce of a given AvN account for different nonce types.
await api.query.getNonce("replace with user's address");
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 { AvnApi, SetupMode, SigningMode } = require("avn-api");
const AVN_GATEWAY_URL = "gateway url of your chosen network";
const options = {
suri: "suri of your account",
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
};
const avnSdk = new AvnApi(AVN_GATEWAY_URL, options);
const ACCOUNT = "5DAgx...";
const NONCE_TYPE = "payment";
async function main() {
await avnSdk.init();
const api = await avnSdk.apis();
//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"
}