Query subscriptions
Last updated
Last updated
Here is an example of how to query subscriptions given their respective index using sub2-sdk. As mentioned , subscriptions are stored in one public array called subscriptions
and are uniquely identified by their index in the array. Since the array is public, we can query all the information of a subscription using their index. Assuming sub2-sdk is installed and initialised like shown , we can query the subscription as follows:
Here, indices
has type bigint[]
.The getSubscription
function returns a promise with a Subscription[] array. Each Subscription object contains both the on-chain data and auxiliary information:
Now we have obtained all information about the subscriptions!