'How to check if NFT is in a specific wallet
I need to check if a specific NFT is in a specific wallet, there is an API or a way to do it programmatically?
Thanks a lot.
Solution 1:[1]
Assuming the NFT is published onchain and its collection contract implements the ERC-721 standard, you can call the ownerOf() function (defined in the standard) on the collection contract.
Example using web3js:
const collection = new web3.eth.Contract(abiJson, collectionAddress);
const owner = await collection.methods.ownerOf(tokenId).call();
return owner == desiredAddress;
For the ERC-1155 standard, you can use the balanceOf() function.
const balance = await collection.methods.balanceOf(owner, ,tokenId).call();
return balance > 0;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
