2

I am trying to retrieve the metadata for a token only using on-chain method such as getProgramAccounts. Unfortunately I cannot use any other language except Python so I cannot make use of libraries such as @metaplex-foundation/mpl-token-metadata, which makes the process a lot easier. I am currently unsure where to start, I will be looking into the Metaplex documentation in the meanwhile in order to maybe get to a solution.

I was hoping someone could maybe lend a hand, not necessarily python code I can use but rather the appropriate account I should be querying, the data structs of these account, their IDLs, what type of bytes offset and data slicing to use with memory comparison when I do getProgramAccounts calls and general tips on how I can retrieve token metadata on-chain. Or if someone maybe has another method which works as well.

1 Answer 1

1

You could use the DAS API and make use of the fetchAsset RPC call.

More info, https://docs.helius.dev/compression-and-das-api/digital-asset-standard-das-api/get-asset

The examples are in JS, but I think converting them to Python should be easy

5
  • I currently use this for my project but I want to move away from relying on an external API. I want a purely on chain solution. Thank you for your suggestion anyways! Commented May 20 at 13:39
  • could you elaborate on what you mean by on-chain. token metadata is stored offchain, except the name and symbol. What do you need from the token metadata?
    – Jimii
    Commented May 20 at 13:42
  • By on-chain I just mean using very fundamental methods to retrieve information from the blockchain without using any third party api or module. I just need name and symbol at the moment. As I understood it, the Metaplex Metadata is stored as a PDA of the mint account of a token, so wouldn't the metadata be stored onchain? Commented May 20 at 13:45
  • you'll need to fetch the account data and deserialize it using a typed Metadata interface, this guide is for TS/JS helius.dev/blog/…
    – Jimii
    Commented May 20 at 13:49
  • 1
    I am aware I have to deserialise account data but I'm unsure of the size of each field in the interface since I would have to reconstruct the interface as a struct in python with all the relevant data fields and their sizes. But I'm sure I'll figure that out on my own. Thanks for your responses anyways. Commented May 20 at 13:54

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.