# approveSale

## Description

The `approveSale` function facilitates the approval of a sale transaction of a non-fungible token (NFT) on the Casper blockchain.

The function makes use of the CasperClient and CEP47Client libraries to interact with the Casper blockchain and returns the transaction hash for the sale approval.

## Parameters

<table><thead><tr><th>Parameter</th><th width="147">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>RPC_API</code></td><td>string</td><td>The RPC API URL of the Casper network</td></tr><tr><td><code>privateKey</code></td><td>string</td><td>The private key of the user</td></tr><tr><td><code>tokenId</code></td><td>number</td><td>The ID of the NFT to be sold</td></tr></tbody></table>

## Response

| Property  | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| `tokenId` | number | The ID of the NFT that was sold           |
| `txHash`  | string | The transaction hash of the sale approval |

## Example Request and Response

### Prerequisites&#x20;

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:

```sh
npm install @nest25/casper-lib
OR
yarn add @nest25/casper-lib
```

### Request

Here is an example of how to make a `approveSale` request using the NO.AI SDK:

```javascript
// import Nest25 Casper library
const { Casper } = require('@nest25/casper-lib');
// create a new Casper instance
const casper = new Casper();

// set testnet variables
const testPrivateKey = 'your-private-key';
const RPC_API = 'https://rpc.testnet.casperlabs.io/rpc';

async function main() {
  // call approveSale function
  const result = await casper.approveSale(RPC_API, testPrivateKey, 872222);
  console.log(result);
}
// call main function
main();
```

### Response

```sh
 {
        tokenId: 872222,
        txHash: '67e8a347a345dfc6718ccaad513df7bc9c33a99b5273ae14f22c90b06585c627'
}
```

## Use Cases

* **NFT Marketplace:** The function can be used by an NFT marketplace to facilitate the sale of NFTs on the Casper blockchain.
* **Individual NFT Owners:** The function can be used by individual NFT owners to approve the sale of their NFTs on the Casper blockchain.
* **NFT Collectors:** The function can be used by NFT collectors to approve the sale of NFTs they wish to acquire on the Casper blockchain.
