3

I need to subscribe to my smart-contract events (#[ink(event)]). So I state_subscribeStorage to "System.Events" storage key. But then I get all system events of all smart contracts in my chain. Can I save websocket traffic and have only events that I am interested in?

Since substrate contract events have topics (#[ink(topic)]), there has to be a way to filter the received events by the topics. Or else why are the topics introduced?

I know about external indexers. But I would like to be simple and use only the substrate node.

1
  • maybe search for storage_changes in the Substrate codebase Commented Jun 20, 2023 at 12:03

1 Answer 1

2

You can use useink and the hook useEvents, which will subscribe to a contract's events. Here is an example using it and decoding the events that are emitted.

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.