1

the title is my question. I really want to know how these third party APIs like Alchemy, Moralis are working I'm building a product and need to create an API which can directly query the Ethereum blockchain and return the metadata of an NFT if I give it the contact address and token ID.

I searched everywhere online but couldn't find anything

3
  • This is a too general question. And, you already gave the basic answer in your post. You can work through the docs of Alchemy or any other 3rd party APIs. docs.alchemy.com You also have another question that covers most part of this question. ethereum.stackexchange.com/questions/137150/…
    – Yetik
    Commented Oct 9, 2022 at 18:33
  • 1
    Does this answer your question? How can I query the onchain data on the ethereum blockchain without using any APIs?
    – Yetik
    Commented Oct 9, 2022 at 22:17
  • If you don't want to use third party APIs then the only option is to write your own indexer that download the blockchain and creates a database that can be used to answer queries. I think blockscout is an opensource block explorer that has functionality for indexing tokens.
    – Ismael
    Commented Oct 15, 2022 at 19:30

2 Answers 2

1

Came across this hackathon project at Eth Global called the "Lindexer" powered by Envio, which pretty much answer the question.

tl;dr NFT metadata is stored off-chain, e.g. decentralized storage such as IPFS or third party hosting. Developer need an API for rich data beyond just what is emitted simply from events on chain.

tl;dr you want to find a reliable indexing solution that supports these arbitrary side processes and instant GraphQL API from the schema of your entities (essentially data model of your DApp).

Lindexer reference "indexes on-chain NFT data, while also indexing NFT meta-data (which is off-chain) in a blazingly fast and concurrent manner to a single database.

This functionality provides an extremely powerful and flexible API to app developers who require rich data beyond just what is emitted simply from events on chain."

0

If you have the NFT tokenId and the NFT implements the openzeppelin‘s ERC721 interface. you can access the ERC721 function:

tokenURI(uint256 tokenId)
Returns the Uniform Resource Identifier (URI) for tokenId token

There you’ll find your json metadata.

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.