verifyNftOwnership - SDK

Checks that the provided owner address owns one or more of the provided NFTs. Returns a boolean indicating whether the owner’s address owns the provided NFT.

Don’t have an API key?

Start using this method in your app today. Get started for free

Description

Checks that the provided owner address owns one or more of the provided NFTs. Returns a boolean indicating whether the owner’s address owns the provided NFT.

Parameters

NameTypeDescription
ownerstringThe owner address to check.
contractAddressstringAn NFT contract address to check ownership for.

Response

PropertyTypeDescription
Promise<boolean | { [contractAddress: string]: boolean }>booleanA boolean indicating whether the owner’s address owns the provided NFT.

Example Request and Response

Prerequisite: You will need to install the Alchemy SDK before making requests with it.

The commands for installing it using npm or yarn are given below:

$npm install alchemy-sdk@latest

Request

index.js
1// Imports the Alchemy SDK
2const { Alchemy, Network } = require("alchemy-sdk");
3
4// Configures the Alchemy SDK
5const config = {
6 apiKey: "alchemy-replit", // Replace with your API key
7 network: Network.ETH_MAINNET, // Replace with your network
8};
9
10// Creates an Alchemy object instance with the config to use for making requests
11const alchemy = new Alchemy(config);
12
13const main = async () => {
14 // define the contract address and owner
15 const address = "0xe5cB067E90D5Cd1F8052B83562Ae670bA4A211a8";
16 const owner = "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D";
17
18 //Call the method to display the rarity of each attribute of the NFT
19 const response = await alchemy.nft.verifyNftOwnership(owner, address)
20
21 //Logging the response to the console
22 console.log(response)
23}
24
25main();

Response

json
1false

Use Cases

Here are some potential use cases for the verifyNftOwnership method:

  • Authenticating ownership during a transaction: When a user wants to sell their NFT, the verifyNftOwnership method can be used to ensure that the seller is the rightful owner of the NFT. This helps prevent fraudulent transactions.

  • Proving ownership for insurance or legal purposes: In cases where the ownership of an NFT is disputed, the verifyNftOwnership method can be used to prove ownership. This can be useful in legal cases or when purchasing insurance for the NFT.

  • NFT lending or borrowing: NFT owners may want to lend their NFTs to others for a fee or borrow NFTs from others. The verifyNftOwnership method can be used to verify ownership before entering into such agreements.

Related Methods

Here are the methods related to verifyNftOwnership: