Sponsored subscriptions

Every subscription has a sponsor which is the account paying the processing fee. By default, the creator of the subscription will be set as sponsor for example if the subscription is created with createSubscription. However, the createSubscriptionWithSponsor function allows creating a subscription with a given sponsor provided a valid signature from that address is provided.

function createSubscriptionWithSponsor(
        SponsorPermit calldata _permit,
        address _sponsor,
        bytes calldata _signature,
        uint256 _index
    ) public returns (uint256 subscriptionIndex);

The signature provided is an EIP-712 signature of the SponsorPermit struct which takes the following form:

struct SponsorPermit {
        uint256 nonce;
        uint256 deadline;
        address recipient;
        uint256 amount;
        address token;
        uint32 cooldown;
        uint32 delay;
        uint32 auctionDuration;
        uint16 initialPayments;
        uint256 maxProcessingFee;
        address processingFeeToken;
    }

Inside SponsorPermit are the parameters used to create the subscription, ensuring the sponsor that their signature can only be used to create a subscription they themselves have signed. Tools for creating and signing a SponsorPermit can be found in the sub2 SDK.

Sponsored payments provide an abstraction for the protocol, allowing users to only pay the exact subscription amount. For instance, an online service provider may sponsor their customers' subscriptions by covering the fees. In this scenario, the service provider generates a signature over a SponsorPermit struct, outlining the terms of the deal. This signature and permit are then used with the createSubscriptionWithSponsor method upon creating the subscription.

Last updated