1

Looking at this transaction for example: https://solscan.io/tx/4oQceeLgtDyHcrhStHsSKXGbC3QAF7CHrtUpeJTuthxuX1uTz3M3NYLsv3RiJ5caJ3yfneAYQ5VqAdQ3ebc8wH1A

Solscan is able to decode the instructions, e.g. #11 "Side". In an EVM chain this isn't as difficult because each contract has an ABI that can help decode the data, events, etc.

But I haven't been able to figure out how to do this on Solana. How can we take the "Instruction Data", e.g. 000a000000010000005483000000000000fa4700000000000020b3666c0e000000020000000200000005aed06b1a84fb8fffff

And decode it into details instructions like a service like Solscan.io is able to do?

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
FinDev
  • 4,437
  • 6
  • 29
  • 29

1 Answers1

2

Unfortunately, the answer is partly that "you have to know" for programs that do not publish an IDL.

For example, solana-py provides instruction decoders for the system program and spl token program. Here's a decoder for one of the system program instructions: https://github.com/michaelhly/solana-py/blob/f41f020938d1fb257142f18608bcb884adb54479/src/solana/system_program.py#L196

For programs that have an IDL, you can take a look at AnchorPy! It should be able to generate a usable client for any Anchor program with an IDL: https://kevinheavey.github.io/anchorpy/

Jon C
  • 7,019
  • 10
  • 17
  • do you know any similar solution to see whats inside instruction data with JS/TS or rust? – kafinsalim Apr 05 '22 at 19:29
  • 1
    Same situation, you need to have an instruction parser available. Here's the parser library for Rust: https://crates.io/crates/solana-transaction-status and the implementation for spl-token: https://github.com/solana-labs/solana/blob/master/transaction-status/src/parse_token.rs in JS, you've got the base programs covered too, like https://github.com/solana-labs/solana/blob/master/web3.js/src/system-program.ts – Jon C Apr 06 '22 at 09:26
  • What does IDL stand for? (Can't find it on google) – Tomvkgames Jun 14 '22 at 23:49
  • It's "Interface Definition Language" or "Interface Description Language": https://en.wikipedia.org/wiki/Interface_description_language – Jon C Jun 16 '22 at 14:07