Skip to main content
Defined in the Base Account SDK
The subscribe function creates recurring USDC subscriptions using spend permissions on the Base network. This enables you to charge users periodically without requiring approval for each transaction. No fees for merchants or users.

Parameters

string
required
Amount of USDC to charge per period (e.g., “10.50”). Maximum 6 decimal places.
string
required
Ethereum address that will be the spender (your application’s address).Pattern: ^0x[0-9a-fA-F]{40}$
number
The period in days for the subscription (e.g., 30 for monthly). Default: 30
boolean
Set to true to use Base Sepolia testnet instead of mainnet. Default: false
boolean
Check if the payer’s wallet has sufficient USDC balance before creating the subscription. If true, subscription creation will fail if the payer doesn’t have enough balance to cover the recurring charge. Default: true
boolean
Whether to enable telemetry logging. Default: true

Returns

SubscriptionResult
Subscription details on success. The function throws an error on failure.

Errors

The subscribe function throws an error when subscription creation fails. The error object contains a message explaining what went wrong.

Error Handling

Always wrap calls to subscribe in a try-catch block: