NFTs – How Opensea Obtains All NFTs of a Wallet

etherscannft

I'm new to this so excuse my n00bness. I created an NFT through Remix on Rinkeby and then log into Opensea and the NFT appears nicely in my account. But how are Opensea finding that data? Are they querying the etherscan API for my transactions and then making additional calls to any ERC721 contracts in list?

Or is there an easier way of doing it with Web3 or another library/service?

Best Answer

Opensea either has a database themselves with all the NFTs of specific addresses, or they use an external API that has this information. Without a database, it's impossible to get this type of information with the speed that is required for a web page.

Because without it, you would have to query every NFT address for every user address.

There is a simple API you can use to accomplish the same thing, the Moralis NFT API. You simple make a call to

/nft/wallet/{owner_address}

This will give you all the NFTs of the specified address. There are also a lot of other great NFT endpoints that you might find useful.

You need an API key, which you can get for free from moralis.io. Full disclosure, I work at Moralis.

Related Topic