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.
This feature requires that the Sub2SDK class is initialized with a private key.
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:
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:
Now we have a signature which you can use to sponsor a subscription!
Reminder: The signature is only valid for a subscription created with the exact details you specified in the SponsorPermit
object! Furthermore, the signature can only be used once.
Last updated