Subscribe
Build subscribe transactions and manage USDC delegation for recurring payments.
Subscribe
buildSubscribeTransaction
Builds the instructions to create an on-chain subscription. Returns the PDA, instructions, and bump seed — you handle signing and sending.
Instructions generated
- SPL Token
approve— delegatesamount × delegationCyclesUSDC to the Subscription PDA initialize_subscription— creates the on-chain PDA with amount, interval, and plan seed
Parameters
| Field | Type | Description |
|---|---|---|
planId | string | Plan identifier from the Recur API |
merchantWallet | string | Merchant's Solana wallet address |
planSeed | string | Hex-encoded 8-byte plan seed (16 chars) |
amount | number | Payment amount in USDC base units (6 decimals) |
intervalSeconds | number | Billing interval in seconds |
delegationCycles | number | Number of payments to pre-approve. Default 12 |
subscribe (high-level)
Full end-to-end flow: build → sign → confirm → register with API.
After the transaction confirms, subscribe calls registerSubscription automatically so the keeper and API are aware of the subscription.
Re-approving an exhausted delegation
When the SPL Token delegation is used up (after delegationCycles payments) or if the subscriber manually revoked it, re-approve without touching subscription state.
buildReapproveTransaction
reapprove (high-level)
Signs, sends, and confirms the re-approval transaction in one call.
Helper: signAndSend
For manual flows you can use the exported helper: