How to give approval to fungible token?

  • approve

This function is used to approve the spending of tokens by another account.

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

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

let params: FTTokenApproveArg = {
  attrib: {
    contract_address: "2e15a979ebc2de6ebafb373dae52e0c1809096c9",
    spender_address: "346fb07c43e88b58c058e8d6c4bf2f5080a01999",
    value: 500000000000000000,
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit?: 100000,
};

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

Parameters:

Approval request object

{
  attrib: {
    contract_address: "2e15a979ebc2de6ebafb373dae52e0c1809096c9",
    spender_address: "346fb07c43e88b58c058e8d6c4bf2f5080a01999",
    value: 500000000000000000,
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit?: 1,
}

Returns:

A promise that resolves with an approval response

{
    "hash": "dc224ba854d5fbd3371f6d509b9a0b5451fff78a70ad3a209b5c273f8da0abfb"
}

Last updated