Skip to content

Feature roadmap: auth, rate limits, x402 payments, accounting #3

@crtahlin

Description

@crtahlin

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 account
  • POST /api/v1/auth/keys - Generate API key
  • DELETE /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 stats
  • GET /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:

  1. Client requests resource
  2. Gateway returns 402 + payment details
  3. Client pays (on-chain or L2)
  4. Gateway verifies payment
  5. Gateway serves resource

Components needed:

  • Payment verification (Base L2, USDC)
  • Pricing configuration
  • Receipt generation
  • Integration with accounting layer

New headers:

  • X-Payment-Required: true
  • X-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

Questions

  1. Which auth method to start with?
  2. X402 on mainnet or testnet first?
  3. Self-hosted vs managed accounting?
  4. Open source the full stack or keep billing private?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions