⛏️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

ParameterTypeDescription

RPC_API

string

The RPC API URL of the Casper network

privateKey

string

The private key of the user

tokenId

number

The ID of the NFT to be sold

Response

PropertyTypeDescription

tokenId

number

The ID of the NFT that was sold

txHash

string

The transaction hash of the sale approval

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/casper-lib
OR
yarn add @nest25/casper-lib

Request

Here is an example of how to make a approveSale request using the Nest SDK:

// 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

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

Last updated