> For the complete documentation index, see [llms.txt](https://sub2.gitbook.io/sub2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sub2.gitbook.io/sub2/sdk/listen-for-incoming-subscriptions.md).

# Listen for incoming subscriptions

In this example, we will use the sub2 SDK to set up a listener for incoming subscriptions to our address. This is useful for anyone who wishes to accept payments with sub2 as you can validate that a subscription has successfully gone through. It is assumed that sub2-sdk is installed and set up as done [here](/sub2/sdk.md).

```javascript
const unwatch: WatchEventReturnType = sub2SDK.watchIncomingSubscriptions(recipientAddress, callbackFn);
```

Here recipientAddress is of type `` `0x{string}` `` and callbackFn is of type `(subscription: Subscription) => any`. The callback function is defined by you and is what is called on newly observed subscriptions to the address. For example, you can make a callback function which checks that the subscription has the correct parameters and if so update your backend and register the user as subscribed.&#x20;

The returned value `unwatch` of the viem type `WatchEventReturnType` is a function that can be called to stop listening for events.
