Skip to main content
Version: 2.4

Transfer Token

Transfer an amount of ERC20 or ERC777 token from the sender account to the recipient account.

await API.send.transferToken(RECIPIENT_ADDRESS, TOKEN_ETHEREUM_ADDRESS, TOKEN_AMOUNT);
important

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

important

You can get the AVN_GATEWAY_URL and Relayer here.

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);

// This can be the address or public key.
const RECIPIENT_ADDRESS = "5DA...gxV";

// The token address on Ethereum.
const TOKEN_ETHEREUM_ADDRESS = "0x2a...b0e";

//amount of the token in 18 decimals.
const TOKEN_AMOUNT = "1234000000000000000"; //i.e. 1.234 of a token

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

let result = await API.send.transferToken(
RECIPIENT_ADDRESS,
TOKEN_ETHEREUM_ADDRESS,
TOKEN_AMOUNT
);
// Returns a request id
console.log(result);
}

(async () => {
await main();
})();


You have now successfully submitted a transaction to the AVN.

tip

You can query the state of your transaction here using the returned result.