stakefy-express
v2.0.0
Published
Express middleware for Stakefy x402 - Drop-in paywalls with 10x lower fees than competitors
Maintainers
Readme
stakefy-express
Express middleware for Stakefy x402 payments. Add payment requirements to your API in 3 lines of code.
🏠 Main Documentation: github.com/JaspSoe/stakefy-x402
📦 Stakefy Ecosystem
This is part of the complete Stakefy payment infrastructure:
| Package | Description | NPM |
|---------|-------------|-----|
| x402-stakefy-sdk | Core SDK | |
| x402-stakefy-react | React hooks |
|
| stakefy-express | Express middleware (this package) |
|
🚀 Quick Start
npm install stakefy-express x402-stakefy-sdk expressimport express from 'express';
import { stakefyPaywall } from 'stakefy-express';
const app = express();
// Protected endpoint - requires 0.01 SOL payment
app.get('/api/premium',
stakefyPaywall({
amount: 0.01,
merchantId: 'YOUR_MERCHANT_WALLET'
}),
(req, res) => {
res.json({ data: 'premium content' });
}
);
app.listen(3000);✨ Features
- ✅ 3-line integration - Add paywalls instantly
- ✅ HTTP 402 compliant - Standard payment required responses
- ✅ Session budgets - Multiple API calls per payment
- ✅ TypeScript support - Full type safety
- ✅ Error handling - Built-in error handling
- ✅ Flexible - Per-endpoint or global middleware
🎯 Examples
API Metering
app.get('/api/ai/generate',
stakefyPaywall({ amount: 0.001, merchantId: 'xxx' }),
async (req, res) => {
const result = await generateAI(req.body.prompt);
res.json({ result });
}
);Session Budget
// Pay once, make multiple calls
app.use('/api/metered',
stakefyBudget({
budget: 0.1,
duration: 3600,
merchantId: 'xxx'
})
);Global Middleware
// Apply to all routes
app.use('/api/v2',
stakefyPaywall({ amount: 0.005, merchantId: 'xxx' })
);📖 Full Documentation
For complete documentation, API reference, and more examples:
Includes:
- Complete API reference
- Advanced examples
- Client integration
- Error handling
- Best practices
🔗 Links
- Main Docs: https://github.com/JaspSoe/stakefy-x402
- Core SDK: https://npmjs.com/package/x402-stakefy-sdk
- React Package: https://npmjs.com/package/x402-stakefy-react
- Facilitator API: https://stakefy-x402-production.up.railway.app
- Twitter: @stakefy
- Email: [email protected]
📄 License
MIT © Stakefy
