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?
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With