Dealing with "logs" field in "Transaction"
Last updated
Was this helpful?
Last updated
Was this helpful?
When working with the data source, "logs" field is the most frequently used field. Since each transaction contains multiple event logs and it could be challenging to transform an array type data field to your desired format. But after this article, you will be an expert.
For example, we want to extract certain values through the logs "LogTrade" from Dydx protocol. (When a trade is made through Dydx, a log called "LogTrade" will be left on the blockchain)
Step 1: We get all the transactions which contain the "LogTrade" event logs.
Finally, from this point on, you can use any field in the data easily.
Step 2: Since each transaction could contain multiple other logs, let's only keep "LogTrade" logs and remove the rest. You can use with a operator.
Step 3: Since some transactions might contain more than one "LogTrade" logs, we can make it even easier to work with by using to flatten the remaining array.