Skip to content

add x402 to daily reports#40

Open
bozp-pzob wants to merge 2 commits intomainfrom
feature/x402
Open

add x402 to daily reports#40
bozp-pzob wants to merge 2 commits intomainfrom
feature/x402

Conversation

@bozp-pzob
Copy link
Owner

@bozp-pzob bozp-pzob commented Sep 3, 2025

MR: Add x402 Payment Integration for Report Access

Summary

This merge request introduces payment-gated access to report endpoints using the x402 protocol. Users can now send on-chain payments to unlock and fetch premium reports generated by the AI News Aggregator.

Details of Change

  • x402 Payment Middleware Integration

    • Added x402-express as a dependency.
    • Configured middleware to protect all routes under /report/*.
    • Routes now require valid x402 payment before returning content.
  • Environment Variables

    • ETHEREUM_WALLET – the receiving wallet address for payments.
    • REPORT_USDC_PRICE – the USDC price required for report access.
    • Both variables are required to enable the paywall.
  • Protected Routes

    • /report/daily → Returns the latest daily JSON report.
    • /report/daily/:date → Returns a specific dated report in YYYY-MM-DD.json format.
    • All additional routes under /report/* will automatically be gated behind the paywall.
  • Error Handling

    • Returns 400 for invalid date formats.
    • Returns 404 if a dated report does not exist.
    • Returns 500 for internal file system errors.

Why This Change?

The AI News Aggregator produces valuable reports enriched with AI processing. Adding an x402-based paywall allows:

  • Monetization of reports with crypto-native payments.
  • Decentralized and programmable access control without relying on centralized payment gateways.
  • Easy extensibility to add pricing tiers or network configurations later.

Example Flow

  1. Client sends a payment request to /report/daily.
  2. The x402-express middleware validates the transaction.
  3. On success, the report JSON file is streamed back to the client.
  4. On failure, the client is blocked with an appropriate error message.

Next Steps / Future Enhancements

  • Add different prices per report type (e.g., summary vs. full dataset).
  • Support multiple networks beyond Base Sepolia.
  • Add signed receipts or usage logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant