How to Query NFT's metadata Onchain

Hello,
I would like to understand how to query metadata onchain.
Let’s assume I want to query metadata of all WomenVSApe NFT (Terra Finder).
What kind of Query request I should do?

1 Like

I also have the need for same functionality. Let me know if anyone has tips on this

Any reply yet on this ? Still waiting

Hello, you can use Querier. Here you have an example of the usage.

1 Like

Hey @Tips @kasunOMG - you are able to do this using Flipside Crypto, linked here.

Flipside has NFT metadata tables for Terra, ETH, and Solana, queryable via SQL.

1 Like

Thanks so much

I am still struggling to retrieve NFT meta data information consistent way.

For example consider the below two NFT collections. (I took these information from lunart and terra finder)

//Hell cats 
contractAddr = "terra1uv9w7aaq6lu2kn0asnvknlcgg2xd5ts57ss7qt"  

//Galactic punks 
contractAddr = "terra103z9cnqm8psy0nyxqtugg6m7xnwvlkqdzm4s4k"

I am able to query these contacts to retrieve the number of tokens using follow lines of code.

terra.wasm.contractQuery(contractAddr, {"num_tokens" :{} }).then( res ={console.log(res.count)})

But below sample code I wrote to retrieve meta data works only for HellCats contract. Not for the galactic punks.

terra.wasm.contractQuery(contractAddr, {"nft_info" :{ "token_id" : "1" // I have checked with multiple token ids } }).then( res => { })

Is there any consistent way I can query the metadata for NFT collections using terra.js (These type of queries can be easily perform for Ethereum, Avalanche, or Solana chains). I must be missing major concept in terra I guess.

The issue with above code is that I assume token id to start from 0 for every collection. Its is not true. I have first query the token ids using “all_tokens” and then use those token ids. The issue was fixed now.

1 Like