How to check if a user has a certain NFT in unity?

Hey, i’m wondering what I did wrong here. I need to check if a user has a certain NFT, but this doesn’t seem to work.

MoralisUnity.Platform.Objects.MoralisUser moralisUser = await Moralis.GetUserAsync();
        Debug.Log(moralisUser.ethAddress);

        NftOwnerCollection NFTs = await Moralis.Web3Api.Account.GetNFTs(moralisUser.ethAddress.ToLower(), ChainList.eth);
        Debug.Log(NFTs.ToJson());

        bool good = false;

        for (int tokenId = 0; tokenId < NFTs.Total; tokenId++) {
            Debug.Log(NFTs.Result[tokenId].TokenAddress);
            if (NFTs.Result[tokenId].TokenAddress == "0xe3F4E587908F1E4b74DFe49F7643303a60B2E9E3") {
                good = true;
                break;
            }
        }
        if (good)
            authKit.SetActive(false);
        else
            notOwnedText.SetActive(true);

Thank you for your help.

getNFTs should also have a parameter where you can specify a list of token addresses and this way you get only the nfts specific to that wallet address and that list of nft contracts

1 Like

Atleast in the documentation, you can’t add any list of token adresses. Maybe there is a separate function, I can’t find it.

Edit: sorry, I was reading the old docs. Thanks.

this is the function from the api equivalent for getNFTs

I’m not sure how to use it in c#.

I’m fine if I get all the NFTs the wallet has, the problem is I think i’m iterating wrong through it.

This part doesn’t work as expected?

Try to use lowercase there