> 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/cancel-subscription.md).

# Cancel subscription

With sub2-sdk you can directly cancel a subscription by providing its index:

```typescript
const transactionReceipt: TransactionReceipt = await sub2SDK.cancelSubscription(index);
```

The cancellation will only go through if the account in the provided walletClient is either the subscriber or the recipient. The returned value of viem type `TransactionReceipt` gives information about the transaction.

{% hint style="warning" %}
**Note:** This performs an on-chain transaction and requires that the sub2SDK object was initialised with a walletClient.
{% endhint %}
