[SOLVED] getNFTforContracts in Web3API.accounts not working

Tried using both the JS and React implementations on: https://v1docs.moralis.io/moralis-dapp/web3-api/account#getnftsforcontract

This error started appearing after migrating from moralis server to parse server.

Note: I attempted the exact implementation of the function in the api docs + my own implementation. Both are giving the same error that token_address is not a known parameter.

Hi @LoneS58

Seems like token_address is now referred as address as per the error message in the image. Please try replacing the token_address with address

When looking for the API params please refer to the latest docs, as the parser server backend code is using the latest Moralis v2 sdk.

In the previous SDK, I used the address param to filter a single result to know the owner of the NFT while it was being created. The implementation looked something of this sort:

Looping with a certain time interval to check if the NFT owned by a certain address pops up on the blockchain. But with the current SDK, I can get a list of tokens within the NFT contract if I remove the token_address param and insert NFT CONTRACT ADDRESS in the address param.

Still, the filtering functionality is lost. Is there another function that can help me achieve something similar?

Now you can use the getNFTs functions. It accepts both address and tokenAddresses params.

address will be the wallet’s address and tokenAddresses is the array of contract addresses.

This should solve your issue. Feel free to reply if you have any other questions.

Which function are we exactly talking about? If I go to the API docs, I can see that there are a few functions under the get NFTs section but there is no getNFTs function.

Which function would be best for my use case where I have to give wallet address and then the tokenAddress as well to filter out the NFT it has received. Its no longer achievable by Get NFTs by contract in both the older and the newer SDKs.

Is this the function you were talking about from the older SDK?
image

getNFTs function is from v1 sdk. Since you are using the v1 sdk on client side code.

Get NFTs by wallet is its equivalent function from v2 sdk. Refer params from this

Yes, that is correct. And btw replace token_addresses with tokenAddresses. In v2 sdk all the param names are in camlecase format.

Alright, thanks! Its functioning now.

1 Like