Get AVT Balance
This page demonstrates how to get the AVT balance of a specific account on the Aventus network.
// replace <acct> with the actual account address
await api.query.getAvtBalance(<acct>);
Example
An example of how you would use this in your code could be:
const AvnApi = require("avn-api");
const GATEWAY = "<node_url>"; //Replace the node_url with the url received from Aventus.
const api = new AvnApi(GATEWAY);
async function main() {
await api.init();
// Return the AVT balance of a specific account
let acctAVTbalance = await api.query.getAvtBalance(<acct>); //replace <acct> with the actual account address
console.log("The AVT balance of an account", acctAVTbalance);
}
(async () => {
await main();
})();
Example Output
930009105441170202155
JSON-RPC
Returns the AVT balance of a given AvN account
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 AVT balance
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":"getAvtBalance", "params":{"accountId": "5GLVUNb9oKLesAjDt17X1N49xyp2fr62sKPAKLgmmNbDB9MH"}, "id":1}'
RESULT FIELDS VALUE - string integer value of the current AVT balance for the account in its smallest denomination.
BODY
{
"jsonrpc": "2.0",
"id": 1,
"result": "930009105441170202155"
}