Subscription Methods
Subscription methods of Azoth SDK for managing subscriptions to creators, platforms, or services.
subscribe()
subscribe()Creates a new subscription.
async subscribe(
author: string,
amount: number | bigint,
period: RatePeriod = RatePeriod.MONTH,
projectId: number
): Promise<ethers.TransactionResponse>Parameters:
author: The address of the creator or platform to subscribe toamount: The amount of tokens for the subscription periodperiod(optional): Subscription period (default: RatePeriod.MONTH)projectId: The project ID associated with the subscription
Returns:
An ethers.js
TransactionResponseobject
Example:
const creatorAddress = '0x...';
const tx = await azoth.subscribe(creatorAddress, 10, RatePeriod.MONTH, 0);
await tx.wait();subscribeBySig()
subscribeBySig()Creates a subscription transaction that can be signed off-chain and executed by anyone.
Parameters:
author: The address of the creator or platformamount: The amount of tokens for the subscription periodperiod(optional): Subscription period (default: RatePeriod.MONTH)projectId: The project ID associated with the subscriptiondeadline: Timestamp after which the transaction cannot be executed
Returns:
An ethers.js
TransactionResponseobject
Example:
unsubscribe()
unsubscribe()Cancel subscription.
Parameters:
author: The address of the creator or platform to unsubscribe from
Returns:
An ethers.js
TransactionResponseobject
Example:
unsubscribeBySig()
unsubscribeBySig()Creates an unsubscribe transaction that can be signed off-chain and executed by anyone.
Parameters:
author: The address of the creator or platformdeadline: Timestamp after which the transaction cannot be executed
Returns:
An ethers.js
TransactionResponseobject
Example:
getSubscriptions()
getSubscriptions()Gets all subscriptions for an account.
Parameters:
account(optional): The address to get subscriptions for. If not provided, uses the connected signer’s address.
Returns:
Array of
Subscriptionobjects, each containing:recipient: The address receiving the subscriptionincomeRate: Rate at which the recipient is receiving tokens (raw format)outgoingRate: Rate at which the subscriber is paying tokens (raw format)projectId: The project ID associated with the subscription
Last updated