4

How can I convert the data to the same form as it is done on the solana explorer for better readability?

enter image description here

1 Answer 1

8

Generally speaking, on-chain transactions are just a bunch of serialized bytes, so to parse it you need to have some more context on what programs it's interacting with. For starters, if it's interacting with a limited amount of solana standard programs, web3.js can parse these out of the box using getParsedTransactions.

This won't work for most programs, though. If you know which program you want to parse, you can try to find it's IDL and use that to parse transactions with anchor. Details on how to do this can be found here.

Finally, if you want to parse a lot of different types of transactions, it basically comes down to collecting and indexing IDLs and matching them with whichever program your transaction is interacting with. Doing this by hand is very tedious, but fortunately there's a couple libraries that do this for you, for example:

https://github.com/solana-fm/explorer-kit

https://github.com/debridge-finance/solana-tx-parser-public

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.