Skip to main content
Version: 3.1.0

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 { AvnApi, SetupMode, SigningMode } = require("avn-api");
const AVN_GATEWAY_URL = "https://gateway.testnet.aventus.network/";

const singleUserOptions = {
suri: "0x5392ca60a61aea99fce14358798de93c1bc11c3696a905718738c71fae539c24", // this is from the generated example account
setupMode: SetupMode.SingleUser,
signingMode: SigningMode.SuriBased,
};
const avnSdk = new AvnApi(AVN_GATEWAY_URL, singleUserOptions);

// 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"; //the wei value of the token amount. Decimals (i.e. 1.234) are not supported.

async function main() {
await avnSdk.init();
const api = await avnSdk.apis();

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.