⛏️checkNFT

Description

The checkNFT function checks the ownership and metadata of a specific non-fungible token (NFT) on the Casper blockchain and returns the NFT's ownership and metadata

Parameters

Name
Type
Description

RPC_API

string

The RPC API endpoint of the Casper blockchain

privateKey

string

The user's private key in string format

tokenId

string

The user's private key in string format

Response

Name
Type
Description

status

number

Indicates if the function was successful (1) or not (0)

balanceOf

number

The balance of the user's account

ownerOfTokenOne

string

The public key of the NFT's owner

tokenOneMeta

object

The metadata of the NFT

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 checkNFT 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 privateKey = 'your-private-key';
const RPC_API = 'https://rpc.testnet.casperlabs.io/rpc';

async function main() {
  // check NFT data using tokenId
  const checkData = await casper.checkNFT(RPC_API, privateKey, '164298');
  console.log(checkData);
}
// call main function
main();

Response

 {
        status: 1,
        balanceOf1: '6',
        ownerOfTokenOne: 'account-hash-b42ea6c352d692cff179749a5023189f92bec6ce81d2c19ad1a1ac2c2c009189',
        tokenOneMeta: Map(4) {
          'description' => 'Bored Ape Mango DESCRIPTION',
          'image' => 'img',
          'name' => 'Bored Ape Mango',
          'royalty' => '40'
        }
}

Use cases

  • NFT marketplaces: The function can be used by NFT marketplaces to verify the ownership and metadata of NFTs before displaying them for sale.

  • NFT collectors: The function can be used by NFT collectors to check the ownership and metadata of NFTs they have acquired.

  • Smart contract developers: The function can be used by smart contract developers to check the ownership and metadata of NFTs in their contracts.

Last updated