forked from crtahlin/swarm_connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
Plan and prioritize additional gateway features beyond basic Swarm operations.
Current State
The gateway provides:
- Stamp management (list, purchase, extend)
- Data upload/download
- Wallet/chequebook info
- Health checks
Proposed Features (Prioritized)
Priority 1: Rate Limiting & Quotas
Why: Prevent abuse, manage costs, fair usage
Implementation:
- Per-IP rate limits (requests/minute)
- Per-user quotas (if auth enabled)
- Upload size limits (already suggested in docs)
- Configurable via environment
Endpoints affected: All
Priority 2: Authentication
Why: Enable user-specific features, billing, access control
Options:
| Method | Pros | Cons |
|---|---|---|
| API Keys | Simple, stateless | Manual management |
| JWT | Standard, claims | Token refresh needed |
| Wallet signature | Web3 native, no passwords | UX complexity |
| OAuth2 | Enterprise-ready | Complex setup |
Suggested: Start with API keys, add wallet auth later
New endpoints:
POST /api/v1/auth/register- Create accountPOST /api/v1/auth/keys- Generate API keyDELETE /api/v1/auth/keys/{id}- Revoke key
Priority 3: Cryptographic Signing
Status: Issue #2 exists
Summary: Sign uploads with user's key or gateway notary service
Priority 4: Usage Tracking & Accounting
Why: Foundation for billing, analytics, quotas
Data to track:
- Uploads: count, bytes, stamps used
- Downloads: count, bytes
- Stamp purchases: count, BZZ spent
- Per-user if auth enabled
Storage: PostgreSQL or similar
New endpoints:
GET /api/v1/usage- Current usage statsGET /api/v1/usage/history- Historical usage
Priority 5: X402 Payment Support
Why: Enable pay-per-use for AI agents, monetization
Spec: HTTP 402 Payment Required flow
Flow:
- Client requests resource
- Gateway returns 402 + payment details
- Client pays (on-chain or L2)
- Gateway verifies payment
- Gateway serves resource
Components needed:
- Payment verification (Base L2, USDC)
- Pricing configuration
- Receipt generation
- Integration with accounting layer
New headers:
X-Payment-Required: trueX-Payment-Address: 0x...X-Payment-Amount: 0.01 USDC
Priority 6: Webhook Notifications
Why: Async notifications for long operations
Events:
- Stamp purchased
- Stamp becoming unusable (low TTL)
- Upload complete
- Large download complete
Priority 7: Admin Dashboard
Why: Operational visibility
Features:
- Usage metrics
- Active users
- Stamp inventory
- Error rates
Implementation Phases
Phase 1 (MVP)
- Rate limiting (IP-based)
- Upload size limits
- Basic usage logging
Phase 2 (Auth)
- API key authentication
- Per-user rate limits
- Usage tracking per user
Phase 3 (Monetization)
- X402 payment flow
- Accounting/billing
- Pricing tiers
Phase 4 (Enterprise)
- Wallet authentication
- Webhooks
- Admin dashboard
Related Issues
- Implement Cryptographically Signed Document Manifests with Optional Gateway Notary Service #2 - Cryptographic signing
Questions
- Which auth method to start with?
- X402 on mainnet or testnet first?
- Self-hosted vs managed accounting?
- Open source the full stack or keep billing private?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels