5

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?

3 Answers 3

1

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.

3
  • Have been playing with the API all afternoon, very cool. I noticed though with the following endpoint that it will only fetch an NFT that is not currently for sale. Is that right? /nft/contract/{token_address}/token/{token_id}
    – highrankin
    Aug 11, 2021 at 20:41
  • 1
    It should include those as well. But it will not include NFTs that are for example up for sale on Opensea expecting a lazy mint. Because if they are up for sale using lazy mint, then that means that the actual token haven't been created yet.
    – Filip
    Aug 12, 2021 at 13:47
  • This path does not actually exist when I tried on the website mentioned:
    – us_david
    Oct 14, 2021 at 19:15
2

I've done some research on this before and concluded that OpenSea saves all the addresses of the ERC721 contract through EtherScan, then loads the contract to look up the NFT and adds a listen on the contract so it knows when someone is creating an NFT or moving an NFT!

While you're doing this, Opensea updates the NFT information to its own server, so when you're done, go to Opensea and you'll see your NFT.Sometimes it's slow, like when the metadata isn't showing, you can click sync.

Hope it works for you!😀

0

This path does not actually exist when I tried on the website mentioned: /nft/wallet/{owner_address}. I tried another: /nft/{address}/{tokenid} with an NFT I minted on opensea, moralis.io DOES NOT return any meta data for it.Actual return from queuing moralis.io:

{
  "message": "No metadata found! Try again later"
}.   

To be clear: when I tested, I used the online admin provided. Here is the request url:

https://deep-index.moralis.io/api/v2/nft/0x2953399124F0cBB46d2CbACD8A89cF0599974963/32549970024550900508417630815706443523178909151161448642787545662360859443201?chain=polygon&format=decimal

Hope folks from the api promoter can point us to the right direction.
By the way, I was able to get info about the same NFT from my dApp.

1
  • Looks like your nft is lazy minted through opensea. So there is no token on chain yet that moralis can fetch info about.
    – Filip
    Oct 16, 2021 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.