1

I've been trying to figure out a way to programmatically derive the descriptive "label" given a program's base58 address, e.g. cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ => NFT Candy Machine V2 or 9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin => Serum DEX V3.

I found a useful answer here using Anchor to get the following data:

"root": {
  "version": "0.0.0",
  "name": "nft_candy_machine", <= this is kind of the data I want
  "instructions": [...],
  "accounts": [...],
  "types": [...],
  "errors": [...]
}

But I want to get the full descriptive label "NFT Candy Machine Program" that explorer.solana.com displays. I've been trying to use solana web3 Connection.getParsedAccountInfo and got so far as getting this result:

{
  info: {
    authority: 'AqH29mZfQFgRpfwaPoTMWSKJ5kqauoc1FwVBRksZyQrt',
    data: [
      'f0VMRgIBAQAAAAAAAAAAAAMA9wABAAAAwB0.......', <= really long base64 encoded value
      'base64'
    ],
    slot: 114756793
  },
  type: 'programData'
}

I tried const parsedData = Buffer.from( info.data[0], info.data[1] ).toString() but it's not giving me the right decoded value.

What is the right way to decode this data?

1 Answer 1

2

The full descriptive label in the explorer is hardcoded https://github.com/solana-labs/solana/blob/5450f978445cff9ac9959d47a7429e0b78c873e3/explorer/src/utils/tx.ts#L66

So there is no way to programmatically obtain this label, the only way would be to have a more descriptive name field embedded in the IDL.

The way you are converting the base64 program data into a buffer is correct const dataBuffer = Buffer.from(...info.data) However, you cannot really do anything from there because this info.data field is the binary of the program to be run by the solana runtime.

3
  • Ah ok, thanks. but do you know how to parse the base64 program data?
    – Sun Lee
    Commented Jul 28, 2022 at 2:48
  • 1
    I edited my reply as the decoded is correct but I doubt this is what you are looking for
    – Arowana
    Commented Jul 28, 2022 at 2:54
  • awesome that's the answer i was looking for, thanks!
    – Sun Lee
    Commented Jul 28, 2022 at 4:52

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.