How to get all the NFTs ever owned by a given address on Ethereum ? #258
-
Dear @PatrickAlphaC , In the NFT Marketplace tutorial, you have shown us how we can listen to events emitted by our contract such as What if I want to know EVERY NFT that exists in the user's Metamask wallet ? (not just the ones minted on our marketplace) Here's my understanding ... and I could be completely wrong ! Please help me If that's true, my question is how can we achieve that ? (opensea seems to have cracked that secret...but they only give us an API to get the same...they don't reveal the underlying logic) You can't possibly monitor EVERY Contract that gets created on chain as well as read the emitted event's logs of all HISTORIC contracts that have been on chain. Like , you would have to go through ...millions and millions of transaction blocks from Day 1. Ain't that nuts ? How tfffffffff does Opensea do it so fast ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
That's exactly what they do 😎 ...sort of. (Keep in mind, this is speculation cuz I can't see their code, but this is how I'd do it) They do it a bit more "on-the-fly". When a user looks up an address, they start indexing on that address and add the results to whatever database they are using. Once they have found all the NFTs an address has, they can easily load that information for next time. So they do a quick listen for all I'm sure they have a pretty big codebase to optimize stuff too. |
Beta Was this translation helpful? Give feedback.
That's exactly what they do 😎
...sort of.
(Keep in mind, this is speculation cuz I can't see their code, but this is how I'd do it)
They do it a bit more "on-the-fly". When a user looks up an address, they start indexing on that address and add the results to whatever database they are using. Once they have found all the NFTs an address has, they can easily load that information for next time.
So they do a quick listen for all
Transfer
events and boom. That's pretty much it.I'm sure they have a pretty big codebase to optimize stuff too.