Set up Complete
Now, let's test our setup and verify that we can perform two actions successfully:
- Query the AVN for data, in this case, the total amount of AVT on the AVN.
- Create an account using the API.
Below is a sample script on how your code should look at this point, to carry out both operations. Please, see comments in the code to understand how the code is divided.
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();
//Query the AVN for data, in this case, the total amount of AVT on the AVN.
const totalAvt = await api.query.getTotalAvt();
console.log("The total amount of AVT on the AVN is: ", totalAvt);
// Generate an account using the API
const account = await api.utils.generateNewAccount();
console.log(account);
}
(async () => {
await main();
})();
Example Output
The total amount of AVT on the AVN is: 5100000000000000000000
danger
Do not use the account details below, as these details are public and are simply an example.
{
mnemonic: 'flag dynamic laptop often park illegal equip curve game blame junior warm',
seed: '0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24',
address: '5EYzWhGxbogEfwNKL52ZRDCgBxu4t8oWDFAsXXVYvH6dMQTo',
publicKey: '0x6e0b67f4590ac2b4e9daa9f229cc4a0c77b3109e8a622e5a1128518ad76e736b'
}
If you had a successful query with a similar result Congratulations! You're all set up to use the AVN Gateway.