Recipe 03: Subscription Service
Automated recurring payments demonstrating blockchain-native subscriptions with LazorKit
The Magic: Sign Once with Face ID, Never Again
This is what makes blockchain subscriptions incredible:
User subscribes with Face ID (gasless via LazorKit)
One Face ID authentication to delegate token spending permission
Automatic charges every billing cycle
Backend service charges the user automatically - no signatures needed!
Cancel anytime (also gasless)
One click to cancel, rent gets refunded automatically
🎯Just like Netflix or Spotify - but decentralized, transparent, and user-controlled!
What We're Building
An automated subscription billing system demonstrating how blockchain-native recurring payments work with LazorKit integration:
- ✓Subscribe with minimal friction (gasless flow via LazorKit)
- ✓Get charged automatically every billing cycle (no user signature needed!)
- ✓Cancel anytime with rent refunds
- ✓View subscription history and payment details
This is a working proof-of-concept showcasing a novel integration pattern with LazorKit.
The Core Innovation: Token Delegation
The key mechanism enabling automatic recurring payments is Solana's token delegation:
// During subscription, user delegates once const delegateIx = createApproveInstruction( userTokenAccount, merchantDelegate, userWallet, amountToDelegate ); // Now merchant can charge automatically // without requiring signatures! 🎉
After this one-time approval with Face ID, the merchant can charge the user automatically without requiring signatures for each payment. This is how blockchain-native subscriptions work - transparent, auditable, and user-controlled.
🚀 LazorKit Integration Benefits
1. Simplified Onboarding
User subscribes with Face ID - LazorKit handles the complexity:
await signAndSendTransaction({
instructions: [
initSubscriptionIx,
delegateTokensIx
],
});2. Gasless User Actions
LazorKit's paymaster covers gas fees for:
- • Canceling subscription
- • Updating preferences
- • Viewing subscription status
This removes friction from the user experience.
3. Smart Wallet Persistence
LazorKit's smart wallets maintain consistent addresses across sessions, important for:
- • Persistent token delegations
- • Stable subscription PDAs
- • Seamless user experience
4. Developer Experience
Simple hooks instead of complex wallet adapter setup:
const { signAndSendTransaction } = useWallet();vs 50+ lines of traditional wallet adapter code
⚠️ Current Limitations & Production Roadmap
This is a proof-of-concept demonstrating feasibility. For production deployment, several enhancements would be needed:
1. PDA Rent Costs (~0.002 SOL)
- • Currently required to create subscription accounts
- • Gets refunded on cancellation
Future Enhancement: Could be sponsored by deploying a custom paymaster for the subscription service, or enhanced LazorKit paymaster integration. Similar to how payment processors charge service fees in Web2.
2. Backend Charging Fees
- • The automated charging service pays transaction fees when pulling funds (this is not charged to the subscribed user)
- • In production, these could be absorbed as business costs
- • Could be covered by a service-specific paymaster
- • Could offset against subscription revenue
Would explore options with LazorKit team to enhance paymaster capabilities.
Why This Matters: Even Web2 subscription services have infrastructure costs (payment processing fees, server costs, etc.). The difference here is transparency about where blockchain costs exist and how they can be optimized. This POC demonstrates that with thoughtful design and LazorKit integration, these costs can be minimized or abstracted away from end users.
Architecture Overview
Frontend (Next.js + LazorKit)
- • Users connect via Face ID
- • Subscribe with gasless flow
- • Manage subscriptions easily
Backend Service
- • Scans for due subscriptions
- • Charges using delegated tokens
- • Handles business logic
Smart Contract (Anchor)
- • Validates delegations
- • Processes charges
- • Manages cancellations
What This Proves
Blockchain-native subscriptions work and can compete with Web2 UX
LazorKit significantly simplifies user experience with Face ID and gasless flows
Cleaner code, faster development with LazorKit's simple hooks
Shows how to combine LazorKit with custom on-chain programs
Clear roadmap for full deployment with identified optimizations
Demonstrates LazorKit can power sophisticated applications beyond simple transfers
This POC demonstrates that with LazorKit integration, building sophisticated on-chain applications becomes more accessible. The patterns shown here can be extended into a full production system with the enhancements outlined above.
Try the Demo
Subscribe to a plan and experience the full flow. Sign once with Face ID, then watch automatic charges happen without any further action!
View Dashboard
Manage your active subscription, view payment history, and see the admin controls for triggering charges.