📌approve

Description

The approve function allows the owner of an ERC721 token to grant approval to another address or contract to transfer the token on their behalf.

Parameters

ParameterTypeDescription

blockchain

string

The blockchain network to use, e.g., Ethereum, Binance Smart Chain

contractAddress

string

The address of the ERC721 contract containing the token

tokenId

string

The ID of the token to approve for transfer

spender

string

The address of the account or contract to grant transfer approval

privateKey

string

The private key of the token owner's account

Response

FieldTypeDescription

code

number

1 for success, 0 for failure

receipt

object

The transaction receipt of the approve transaction

Example Request and Response

Prerequisites

Before making requests with NEST® SDK, you must have it installed.

You can install NEST® SDK using either npm or yarn. Use the following commands to install NEST® SDK:

npm install @nest25/evm-chains-lib
OR
yarn add @nest25/evm-chains-lib

Request

Here is an example of how to make a approve request using the NEST® SDK:

const {ERC721} = require('@nest25/evm-chains-lib')
// create a new wallet instance
const erc721 = new ERC721();
const privateKey = "your private key here"

const main = async () => {
    // approve erc721 token
    const receipt=await erc721.approve(
        'klay',
        '0xE4eD9066bD1A34994445cAd01Cb9A73A59b8A045',
        '1',
        '0xE668C72D4C67236A712Ce69A91C74358586f31ed',
        privateKey
        )
    // print receipt
    console.log(receipt);
}
main()

Response

  

Use Cases

  • Crypto wallets: They can use this function to grant approval to other addresses or contracts to transfer their ERC721 tokens on their behalf.

  • DApp developers: Developers can use this function to enable users to grant approval to their smart contracts to transfer their ERC721 tokens.

Last updated