> For the complete documentation index, see [llms.txt](https://docs.ramper.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ramper.xyz/embedded-wallet-sdk/quickstart/for-web-apps/multichain-supported/approve-nft.md).

# Approve NFT

## Approve Single NFT

{% tabs %}
{% tab title="Code Example" %}
{% code title="approve-nft.tsx" fullWidth="true" %}

```javascript
import {
  approveToken,
  ApproveTypes,
  RawTransaction
} from "@ramper-v2/multi";
import Web3 from "web3";
import { CHAIN_DATA } from "@wallet/constants";
 
const rpcURL = CHAIN_DATA[chain].rpcURL;
const client = new Web3(
  new Web3.providers.HttpProvider(rpcURL)
);
 
const approveNFTData = {
  approveContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
  spender: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
  tokenID: '2443'
}
 
 
const handleApproveNFT = async () => {
  try {
    const { approveContract, spender, tokenID } = approveNFTData;
 
    if (!approveContract || !chain) return;
 
    const contract = new client.eth.Contract(
      ERC721ABI as any,
        approveContract
      );
    const dataraw = contract.methods.approve(spender, tokenID);
    const rawTransaction: RawTransaction = {
      data: dataraw.encodeABI(),
      to: approveContract,
    };
 
    const result = await approveToken({
      transaction: rawTransaction,
      options: {
        type: ApproveTypes.NFT,
      },
      chain,
    });
  } catch (error) {
    // Error Handler
  }
};
```

{% endcode %}
{% endtab %}

{% tab title="Demo UI" %}

<figure><img src="/files/SS2vY7Q2Sgu6IJSGwAOI" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Approve NFT Collection

{% tabs %}
{% tab title="Code Example" %}
{% code title="approve-nft-collection.tsx" fullWidth="true" %}

```javascript
import {
  approveToken,
  ApproveTypes
} from "@ramper-v2/multi";
import Web3 from "web3";
import { CHAIN_DATA } from "@wallet/constants";
 
const rpcURL = CHAIN_DATA[chain].rpcURL;
 
const approveNFTCollectionData = {
  approveContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
  spender: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
  tokenID: '2443'
}
 
const client = new Web3(
  new Web3.providers.HttpProvider(rpcURL)
);
 
const handleApproveNFTCollection = async () => {
  try {
    const { approveContract, spender } = approveNFTCollectionData;
 
    const contract = new client.eth.Contract(
      ERC721ABI as any,
      approveContract
    );
    const dataraw = contract.methods.setApprovalForAll(spender, true);
    const rawTransaction: RawTransaction = {
      data: dataraw.encodeABI(),
      to: approveContract,
    };
 
    const result = await approveToken(rawTransaction, {
      type: ApproveTypes.NFTCOLLECTION,
    });
  } catch (error) {
    // Error Handler
  }
};
```

{% endcode %}
{% endtab %}

{% tab title="Demo UI" %}

<figure><img src="/files/crpUG8S93OVYsIo3sdPl" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.ramper.xyz/embedded-wallet-sdk/quickstart/for-web-apps/multichain-supported/approve-nft.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.
