Skip to main content

Method Signature

align.blockchain.nfts.getOwner(
  contractAddress: string,
  tokenId: string,
  network: Network
): Promise<string>

Parameters

contractAddress
string
required
ERC-721 contract address
tokenId
string
required
Token ID to query
network
string
required
Network where the NFT exists

Returns

Returns the owner’s wallet address as a string.

Examples

import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

const owner = await align.blockchain.nfts.getOwner(
  "0xNFTContractAddress...",
  "123",
  "polygon"
);

console.log(`Token #123 is owned by: ${owner}`);

Verify Ownership

const owner = await align.blockchain.nfts.getOwner(
  nftContract,
  tokenId,
  "polygon"
);

const myAddress = wallet.address.toLowerCase();
const isOwner = owner.toLowerCase() === myAddress;

if (isOwner) {
  console.log("You own this NFT!");
} else {
  console.log(`NFT is owned by ${owner}`);
}