How to parse transaction event logs?

Hi, folks. I have a task to parse some information from transactions. For example, in Ethereum, this is called event logs. Smart contracts have events (Mint, Transfer, Sale). Is there anything like this in Solana? If so, is it possible to implement it now on Golang or js?

Hi @osmgosha and welcome to the forum! :wave:

I’m not acquainted with event logs in Ethereum, but Solana does have the ability to subscribe in realtime to certain occurrences on the chain. You can see exactly what functions are available by looking at all of the functions that start with on such as onAccountChange or onSlotUpdate in the web3.js API’s Connection object:

In order to watch for specific types of changes you have to have some knowledge about the way that the data you are interested in is stored by the smart contract that implements the functionality.

Then you have to watch for changes to the program accounts that store the information you are watching using onProgramAccountChange. This function will allow you to specify a callback that will get notified of any changes to the program account data, and you will have to derserialize the account data so that you can get the info you need.

Let me know if you need some more specific pointers on how to do something.

1 Like

Thank you so much for helping!

1 Like