Sync nft for all authenticated users

I want to sync all NFTs of a specific collection (contract) that are owned by the users who connect to the app.

So instead of showing all NFTs from a collection I only want to show the ones from the users who are authenticated and in the database.

Is something like this possible?

It would also have to listen to contract events to remove NFTs if sold or transferred to users who are not connected to the app.

You can use getnftsforcontract function to get NFTs of a user from the contract. These results will also get updated after NFT transfers.
https://docs.moralis.io/moralis-dapp/web3-api/nft-api#getnftsforcontract

1 Like

Great thanks, so no query to get all of the NFTs from a collection across all users who are in the Moralis database?

Looping through everyone is resource-intensive and likely will need more requests than the rate limit allows.

Would it be possible to save the results of getnftsforcontract into a new database class and setup a sync event to watch for transfers and update the DB automatically? Any documentation on anything like that?

maybe you want to do something similar to this:

1 Like

Sweet I’ll check that out

Thanks!

1 Like