Scout Chart Creator
Search…
Dealing with "logs" field in "Transaction"
When working with the Transaction 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.
Fin all the transactions which have "LogTrade"
Step 2: Since each transaction could contain multiple other logs, let's only keep "LogTrade" logs and remove the rest. You can use Project with a filter operator.
Use "filter" to only keep "LogTrade" logs
Step 3: Since some transactions might contain more than one "LogTrade" logs, we can make it even easier to work with by using Unwind to flatten the remaining array.
Use "Unwind" to flatten the array.
Finally, from this point on, you can use any field in the data easily.
Last modified 1yr ago
Copy link