Skip to main content
Version: 1.0

The End to End Guide For Transferring Tokens 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 set up your Substrate uri (SURI) as an environmental variable here. Setting your environmental variable makes things easier going forward.

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, you'll need 1 AVT in your SURI account to use the API. The tokens need to be lifted (moved) to the Aventus Network, and there are also instructions for that too here.

Once you have some AVT in your account, of which you can check your account balance 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 X tokens from one account to another.

important

This operation uses a relayer account that the sender authorizes to submit the transfer transaction. You can learn more about relayers HERE.

You can get the AVN_GATEWAY_URL and AVN_RELAYER here.

const AVN_API = require("avn-api");
const AVN_GATEWAY_URL = "<node_url>";
const API = new AVN_API(AVN_GATEWAY_URL);

const AVN_RELAYER = "5FbUQ...";


const RECIPIENT_ACCOUNT = "5ab310...";
const TOKEN_CONTRACT = "0x1234...";
// Amount to Transfer
const AMOUNT = "10000000000000000000";

async function main() {
await API.init();

let requestId = await API.send.transferToken(
AVN_RELAYER,
RECIPIENT_ACCOUNT,
TOKEN_CONTRACT,
amount
);
// Save the request id of the transaction.
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:

let status = await api.poll.requestState(requestId);
console.log(status);

Expected State Output

{
"txHash": "0x37b5aa6...ae1c773c0acbc63dc90",
"status": "Processed",
"blockNumber": "125412",
"transactionIndex": "2"
}