How to get an allowence of fungible tokens?

  • getAllowance

This function is used to retrieve the allowance for spending tokens on behalf of an owner.

import { L1XProvider, FTTokenGetAllowanceArg } from "@l1x/l1x-wallet-sdk";

let l1xProvider = new L1XProvider({
  clusterType: "mainnet",
  endpoint: "https://v2-mainnet-rpc.l1x.foundation",
});

let params: FTTokenGetAllowanceArg = {
  contract_address: "2e15a979ebc2de6ebafb373dae52e0c1809096c9",
  owner_address: "346fb07c43e88b58c058e8d6c4bf2f5080a01999",
  spender_address: "f060c5232a76cd8cfb931c1e199cfd5dc2e4ee07",
};

l1xProvider.tokens.FT.getAllowance(params)
  .then((response) => console.log(response)) // log response
  .catch((err) => console.error(err)); // log error

Parameters:

Allowance query parameters.

{
    "contract_address": "2e15a979ebc2de6ebafb373dae52e0c1809096c9",
    "owner_address": "346fb07c43e88b58c058e8d6c4bf2f5080a01999",
    "spender_address": "f060c5232a76cd8cfb931c1e199cfd5dc2e4ee07"
}

Returns:

A promise that resolves with an allowance response

{
    "value": "34253522",
    "decimals": 12,
    "normalized_value": "253826612223"
}

Last updated