0

I have a customer that wants to know if a specific public address, accessing his API, owns a specific NFT.

I just implemented a athentication system based on wallet nonce signing, using metamask by now, and seamless integrate into aspnet authentication and identity. It seems that was the tricky part, but now I'm stuck trying to figure out how to lookup if the NFT is owned by the account.

There are lots of answers that claim use that api or that other one, but seems that no one knows about the "manual" process to program than using API call(s). I like to unleash the full power of aspnet services, and also we can use Nethereum as intermediate library to interact with the blockchain, but it seems to be a gap in the information available about how to do that lookup.

I'm really new using that not-so-descentralized web3 tech, but i'm 30 years experienced programmer... So can anyone gimme some clues about how to model the process of querying for a specific NFT is owned by an specific Public Address?

Thanks in advance and excuse my bad english.

2
  • Haven't done blockchain for a few years now. But "back in my days", the only way to check, yourself, if an address owns a NFT is, knowing the contract address, scan the blockchain for all transaction to and from the contract and check if the "nft balance" of a user address is positive. Commented Jul 12, 2023 at 6:50
  • Hey, By specific NFT are you referring to NFT contract address or an NFT id?
    – JohnVersus
    Commented Jul 12, 2023 at 9:38

1 Answer 1

0

I assume from your question that you have a specific NFT that you want to check if an already authenticated wallet address owns it or not.

For a ERC721 NFT you would can check that by calling the ownerOf() function in the NFT smart contract. Pass in the token ID and it will return the owner of that NFT, which you then can compare to the authenticated users address.

For a ERC1155 NFT you would instead call the balanceOf() function and pass in the wallet address and the token ID. This will return an integer with the balance of that token in the users wallet. If it's greater than 0 then you know that the authenticated users owns that particular NFT.

You can see how to make smart contract function calls with Nethereum here.

However, in order to call smart contract functions you're going to need either your own blockchain node or an external RPC API like infura to make those calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.