3

I'm looking to subscribe to events emitted from a contract.

I am currently creating a storage key for System Events, subscribing to it and filtering the events to get the one emitted by the contract I am interested in.

Is there a better way to subscribe to the events of a specific contract?

1

1 Answer 1

2

You can use subquery event handler to capture the desired events. It supports filtering based on Modules (the contracts module in this case) and Methods.

This filters all events of all contracts. But to filter the events for a specific contract, you'll have to subscribe to the contract's entity in the schema, and filter this subscription with the contract address

4
  • Thank you. But, I'm building a Go client and am currently working on extending this github.com/torusresearch/go-substrate-rpc-client for contracts.
    – Kanishka
    Commented Aug 17, 2022 at 11:10
  • I also tried to use Contracts as the module, it doesn't have the storage for Events
    – Kanishka
    Commented Aug 18, 2022 at 13:41
  • I'd use centrifuge rather than that fork as it looks like more dev is on centrifuge's original though I can't see ink support commits - maybe ask that question in that projects github issue asking for support?
    – Squirrel
    Commented Aug 28, 2022 at 8:39
  • Sorry, I meant to include Centrifuge's repo there. That's our fork where we're working on extending it to support contracts. But, my question is more related towards the RPC support in substrate itself. I mean, if substrate has something for it, I could use it irrespective of the library.
    – Kanishka
    Commented Sep 20, 2022 at 7:08

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.