Web3 API GetNFTs latest info

Hi all,

I’m using moralis web3 API to get the NFT of a user for a specific collection. I’m really loving working with moralis but there’s just one issue I’m currently facing. I have a collection on rinkeby and I’m having trouble getting the latest information on that collection. For example I have once account that minted 18 NFTs but the web3 api only returns 15. I have another account that minted 3 but moralis returns 0.

Is there a way to make moralis update to the latest info or watch the nft contract? Also, could this just be a testnet issue or is there something I have to always do to ensure moralis fetches the latest information. Thanks!

  • Edit. The three of the second account have been found now, but still having issues finding the 3 missin from the first account. So the question is basically: is there any way I can improve the web3 api for my particular collection?

Can you give examples for those cases where it doesn’t work now?

Moralis code:

const usersNFTs = await Web3Api.account.getNFTs(options);
            if (usersNFTs) {
                /*console.log(usersNFTs.result.sort((a,b) => {
                    let _ba = parseInt(a.block_number)
                    let _bb = parseInt(b.block_number);

                    if (_ba > _bb)
                        return 1
                    else if (_ba < _bb)
                        return -1
                        return 0
                let usersAbstractions = usersNFTs.result.filter(r => r.token_address.toLowerCase() === contract.address.toLowerCase())
                console.log(`Your balance: ${_balance} | NFTs found: ${usersAbstractions.length}`)

Resulting console log

Etherscan balance

Can you paste that address?

Contract: 0x76C6A80d876c892791C552810EBcd2B9ec8C2781
My wallet: 0x9Cc3d5291D1dc1C2E3c49f002CC31eeDBB687c0f
Network: Rinkeby

After first 3-5 mints it works fine but the first 3-5 mints of the collection seem to have this problem

You say that it works fine now, but it took 3-4 minutes until the info was available in web3api?

No I’m saying that for this wallet it’s only found 15/18 NFTs. For all subsequent mints / accounts it’s working fine but for this account it’s not retrieving 3 out of 18.

Anyway, is there any way to make moralis update this data or something like that from my side?
Appreciate the help btw!

x = await Moralis.Web3API.account.getNFTsForContract({"chain":"rinkeby","address":"0x9Cc3d5291D1dc1C2E3c49f002CC31eeDBB687c0f","token_address":"0x76C6A80d876c892791C552810EBcd2B9ec8C2781"} )


{total: 26, page: 0, page_size: 500, result: Array(26), status: 'SYNCED'}

what I’m doing wrong?

Thanks for the answer! I was using the getNFTs instead of getNFTsForContract method. This has solved the issue. Thank you very much for the help.

Final question. Is there anything more I can do to ensure the latest data for my contract is synced? Or does moralis take care of that automatically

Moralis should take care of that automatically, but when you see problem you can post here in forum

Alright! Any resource I can read to understand how you guys are syncing so much contract data? Really curious about that

Moralis is doing that processing on scale and saving the processed data in an intermediate database