Skip to main content
Version: 4.0.0

Lower Tokens

Triggers a "lower" of an amount of ETH or any available ERC20 or ERC777 token, deducting the amount from the sender's AvN account.

The process is completed on Ethereum by calling the AvN tier1 contract's lower method after a summary containing the transaction has been published, in order for the recipient to receive the lowered amount. Once this trigger transaction is completed, it takes 24 hours before the data required to complete step-2 of the lower transaction is available. After 24 hours, you can query for the claimData using this. The claimData object contains two values: the leafData and the path. You'll need both to submit the Ethereum transaction.

await api.send.lowerToken(
RECIPIENT_ETHEREUM_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 here.

const AVN_API = require("avn-api");
const AVN_GATEWAY_URL = "<node_url>";
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);

// The recipient's ethereum address
const RECIPIENT_ETHEREUM_ADDRESS = "0xfA2...a46";

const TOKEN_ETHEREUM_ADDRESS = 0;

// The amount of the ERC token to be lowered in 18 decimals form. Dot decimals are not supported (e.g 2.4)
const TOKEN_AMOUNT = "300";

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

let request_id = await api.send.lowerToken(
RECIPIENT_ETHEREUM_ADDRESS,
TOKEN_ETHEREUM_ADDRESS,
TOKEN_AMOUNT
);
// Returns a request id
console.log(request_id);
}

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


tip

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