# 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

| Parameter         | Type   | Description                                                        |
| ----------------- | ------ | ------------------------------------------------------------------ |
| `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

| Field     | Type   | Description                                        |
| --------- | ------ | -------------------------------------------------- |
| `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 NO.AI SDK, you must have it installed.

You can install NO.AI SDK using either **`npm`** or **`yarn`**. Use the following commands to install NO.AI SDK:

```jsx
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 NO.AI SDK:

```jsx
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

```jsx
  
```

## 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.non-obvious.ai/sdks-guide/blockchain-sdks/evm-chains-sdk/contracts/erc721/approve.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
