Defined in the Base Account SDK
Base Subscriptions enable recurring USDC payments. Users grant your application permission to charge their account periodically, eliminating the need for manual approvals on each payment. No fees for merchants or users.
How Subscriptions Work
User Creates Subscription
User approves a spend permission for your application to charge a specific amount periodically.
Application Charges Periodically
Your backend charges the subscription when payment is due, up to the permitted amount per period.
Automatic Period Reset
The spending limit resets automatically at the start of each new period.
User Can Cancel Anytime
Users maintain full control and can revoke the permission at any time.
Core Functions
subscribe Create a new subscription with spend permissions
getStatus Check subscription status and remaining charges
charge Charge a subscription from your backend (Node.js only)
revoke Cancel a subscription from your backend (Node.js only)
getOrCreateSubscriptionOwnerWallet Setup CDP smart wallet for subscription management (Node.js only)
prepareCharge Advanced: Prepare transaction calls to charge a subscription
prepareRevoke Advanced: Prepare transaction calls to revoke a subscription
Type Definitions
// Subscription creation options
interface SubscriptionOptions {
recurringCharge : string ;
subscriptionOwner : string ;
periodInDays ?: number ;
testnet ?: boolean ;
telemetry ?: boolean ;
}
// Subscription result
interface SubscriptionResult {
id : string ;
subscriptionOwner : Address ;
subscriptionPayer : Address ;
recurringCharge : string ;
periodInDays : number ;
}
// Subscription status
interface SubscriptionStatus {
isSubscribed : boolean ;
recurringCharge : string ;
remainingChargeInPeriod ?: string ;
currentPeriodStart ?: Date ;
nextPeriodStart ?: Date ;
periodInDays ?: number ;
}
// Charge options (Node.js backend only)
interface ChargeOptions {
id : string ;
amount : string | 'max-remaining-charge' ;
paymasterUrl ?: string ;
recipient ?: Address ;
testnet ?: boolean ;
}
// Charge result
interface ChargeResult {
id : string ;
amount : string ;
recipient ?: Address ;
}
// Revoke options (Node.js backend only)
interface RevokeOptions {
id : string ;
paymasterUrl ?: string ;
testnet ?: boolean ;
}
// Revoke result
interface RevokeResult {
id : string ;
}
// Subscription owner wallet setup (Node.js backend only)
interface GetOrCreateSubscriptionOwnerWalletOptions {
walletName ?: string ;
}
interface SubscriptionOwnerWallet {
address : Address ;
walletName : string ;
}
// Charge preparation (advanced)
interface PrepareChargeOptions {
id : string ;
amount : string | 'max-remaining-charge' ;
recipient ?: Address ;
testnet ?: boolean ;
}
type PrepareChargeResult = Array <{
to : Address ;
data : Hex ;
value : '0x0' ;
}>;
// Revoke preparation (advanced)
interface PrepareRevokeOptions {
id : string ;
testnet ?: boolean ;
}
type PrepareRevokeResult = {
to : Address ;
data : Hex ;
value : '0x0' ;
};
Next Steps
Accept Recurring Payments Guide Learn how to implement recurring payments with Base Pay
One-Time Payments Guide Learn how to implement one-time payments with Base Pay
Spend Permissions Deep dive into Spend Permissions