1

I was wondering if there is a JSON-RPC method similar to eth_getLogs.

What I would like to accomplish is to query all the events that meet a certain criteria, and that happened after a certain block. I'm sure that there must be a way to accomplish this, but I haven't found any documentation that explains how.

Could anyone please let me know what's the JSON-RPC method that should be used and how it should be consumed? I would also like to know what's the correct way to encode the topics so that I can query events that meet a certain criteria.

For instance, how could I query all the balances.Transfer events that took place for a certain "sending" Address after a given block? If someone could please share an example of how that JSON-RPC call would look like, that would be perfect.

Thanks!

1 Answer 1

1

I believe you'll need to iterate over blocks to query events (see this answer for tips), or use an indexer (look here for an overview of available solutions).

4
  • Hi Adam! Thanks for the answer! However, I want to believe that there is a better way to accomplish this :-) Actually, I think that I'm getting closer: there is a system.eventTopics storage call that returns a vector of a tuple with the blocks-indexes that match the given topic... So, now I just need to find out how to compute the hash of the topic. I'm trying to find documentation around that, but no luck so far... wish me luck! ;-)
    – Josep
    Oct 27, 2022 at 9:07
  • Actually... I take it back, I think that I was mistaken and there is no way to accomplish this on substrate 😞. B/c I just noticed that on substrate when defining events, there is no way to flag some of their args as indexed... Therefore, the topic must be the topic of the "generic" event, and there probably is no way to build a narrower query... :/
    – Josep
    Oct 27, 2022 at 9:33
  • 1
    Oh, wait, no... apparently there is a way to store the events so that they can be indexed given a list of topics... 🤔 it's just that's not the default way of storing the events, but it can be done... I still don't quite understand how the system.eventTopics should be used in that case... I guess that I will open a different question. Thanks!
    – Josep
    Oct 27, 2022 at 10:14
  • I asked this question here substrate.stackexchange.com/questions/8411/… May 16 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.