Listen for canceled subscriptions
Similar to how we can use the sub2 SDK to listen to new subscriptions for a given recipient, we can also listen to canceled subscriptions. It is assumed that sub2-sdk is installed and setup as done here.
Here recipientAddress
is of type `0x{string}`
and callbackFn is of type (subscriptionIndex: bigint) => any
. The callback function is defined by you and is what is called on newly observed canceled subscriptions. For example, you can make a callback function which checks that the subscription index corresponds to an active subscription in your backend and update access accordingly.
The returned value unwatch
of the viem type WatchEventReturnType
is a function that can be called to stop listening for events.
Last updated