How to approve a spender to manage a specific Non-Fungible token?

  • approve

Approves a spender to manage a specific NFT token.

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

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

let params: NFTApproveArg = {
  attrib: {
    contract_address: "cf0289e86714d97979d726eeb2fa3a23b9c007c1",
    spender_address: "346fb07c43e88b58c058e8d6c4bf2f5080a01999",
    token_id: "123",
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 0,
};

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

Parameters:

The attribute for approving token management.

{
  attrib: {
    contract_address: "cf0289e86714d97979d726eeb2fa3a23b9c007c1",
    spender_address: "346fb07c43e88b58c058e8d6c4bf2f5080a01999",
    token_id: "123",
  },
  private_key: "YOUR_PRIVATE_KEY",
  fee_limit: 0,
}

Returns:

The response of the approval operation.

{
    "hash": "dc224ba854d5fbd3371f6d509b9a0b5451fff78a70ad3a209b5c273f8da0abfb"
}

Last updated