Sponsor subscriptions
The sub2 SDK can be used to generate EIP-712 signatures used for sponsoring new subscriptions. As mentioned here, sponsoring a subscription means that all processing fees are paid by you.
To sponsor a subscription, we first have to specify the details of the subscription we wish to sponsor. This is done by creating a SponsorPermit
object which can be imported directly from sub2-sdk:
interface SponsorPermit {
nonce: bigint,
deadline: bigint,
recipient: `0x${string}`,
amount: bigint,
token: `0x${string}`,
cooldown: number,
delay: number,
auctionDuration: number,
initialPayments: number,
maxProcessingFee: bigint,
processingFeeToken: `0x${string}`
}
The nonce an uint256
value which cannot be used by a signature previously. In practice this can be set to a random uint256
value as the chance of collision is infinitely small. The deadline is the UNIX time in seconds when the signature will expire. After this time, the signature will no longer be valid.
Once we have a sponsor permit, we can use the SDK to generate a signature:
const signature: `0x${string}` = await sub2SDK.generateSponsorSignature(sponsorPermit);
Now we have a signature which you can use to sponsor a subscription!
Last updated