The End to End Guide For Transferring AVT between accounts on the AVN
This guide will walk you through successfully submitting a transaction to the AVN and verifying the state of the transaction.
The first thing we need to do is ensure that you have npm
installed. You'll find instructions on how to do this here. You'll also find instructions on how to install the avn-api library. Once that's done, the next step is to think about how you would like to go about setting up your Substrate uri (SURI). You can either do this as an environmental variable or as an option during initialisation. Both options are here. For this guide, we'll use the options
method.
Note, all transactions on the AVN must be paid for using AVT, so going forward it's important for you to have some AVT in your account. There are multiple ways to purchase AVT and this page provides instructions on how to get some. Note: If you haven't submitted a transaction on the AvN previously, you need a minimum of 1 AVT in your account to use the API. The AVT needs to be lifted (moved) to the Aventus Network, and there are also instructions for that too here. If you have a designated account registered on the Gateway to pay your fees, your account is not subject to pay transaction fees or have the 1 AVT balance requirement.
Once you have some AVT in your account, of which you can check your account balance by using the explorer here, let's get to the exciting bit, submitting a transaction to the AVN. For this guide, we'll show a simple transaction submitting 10 AVT from one account to another.
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 AVN_RELAYER = "5FbUQ...";
// Amount to Transfer (10 with 18 decimals)
const AMOUNT = "10000000000000000000";
// The AvN address or public key of the recipient account.
const RECIPIENT_ACCOUNT = "5ab310...";
async function main() {
await api.init();
const requestId = await api.send.transferAvt(
AVN_RELAYER,
RECIPIENT_ACCOUNT,
AMOUNT
);
// returns a request id
console.log(requestId);
}
(async () => {
await main();
})();
Expected Transaction Submission Output
f1710fe7-141f-43c1-b1bb-6ec33d9b3e9a
Congratulations! You've now successfully submitted a transaction to the AVN.
State of the Transaction
To query the AvN on the state of the transaction, you can poll the state.
Expected State Output
{
"txHash": "0x37b5aa6...ae1c773c0acbc63dc90",
"status": "Processed",
"blockNumber": "125412",
"transactionIndex": "2"
}