Skip to content

0xsupremedev/microapi-hub

Repository files navigation

πŸš€ MicroAPI Hub

Complete x402 (Solana) payment protocol implementation for API monetization

License TypeScript Solana Next.js Node.js

image image

Built for the Solana X402 Hackathon πŸ†

Features β€’ Architecture β€’ Quick Start β€’ Documentation β€’ Contributing


πŸ“‹ Table of Contents


🎯 Overview

MicroAPI Hub is a complete end-to-end implementation of the x402 payment protocol for Solana, enabling API providers to monetize their endpoints with blockchain payments. This project demonstrates how to build a production-ready payment system that integrates seamlessly with Solana's blockchain.

What is x402?

x402 is an open payment standard that enables clients to pay for external resources (APIs, content, data) using blockchain payments. It follows HTTP status code 402 (Payment Required) semantics and provides a standardized way to implement pay-per-use APIs with on-chain settlement and verifiable receipts.

Key Highlights

  • βœ… Full Protocol Compliance: Complete x402 specification implementation
  • βœ… Solana Integration: Native SOL and SPL token support
  • βœ… Production-Ready: Error handling, validation, logging, testing
  • βœ… Developer-Friendly: Comprehensive docs, code examples, easy integration
  • βœ… On-Chain Registry: Decentralized API discovery
  • βœ… Multi-Language Support: TypeScript, Python, Go examples

✨ Features

πŸ” Payment Processing

  • Payment Verification: Cryptographically secure signature verification
  • On-Chain Settlement: Automatic blockchain transaction processing
  • Multi-Token Support: Native SOL and SPL tokens (USDC, etc.)
  • Nonce Replay Protection: Prevents double-spending attacks
  • Time Window Validation: Ensures payment freshness

🌐 Web Interface

  • Wallet Integration: Connect with Phantom, Solflare, and other Solana wallets
  • Payment Modal: User-friendly payment flow with real-time status
  • Transaction History: View and verify all payment receipts
  • Resource Discovery: Browse available paid APIs
  • Receipt Viewer: Verify transactions on Solscan

πŸ”§ Developer Tools

  • RESTful API: Standard HTTP endpoints
  • Discovery Endpoint: .well-known/x402 protocol compliance
  • Code Examples: TypeScript, Python, Go implementations
  • Comprehensive Docs: API reference, developer guide, tutorials
  • E2E Testing: Complete test suite

πŸ“Š On-Chain Registry

  • Decentralized Discovery: Query APIs from Solana blockchain
  • Provider Registration: Register your API on-chain
  • Category Organization: Organize APIs by type
  • Active/Inactive Management: Control API availability

πŸ› οΈ Tech Stack

Backend

  • Node.js Node.js 18+ - Runtime environment
  • TypeScript TypeScript 5.6 - Type-safe development
  • Express Express.js - Web framework
  • Zod Zod - Schema validation

Blockchain

  • Solana Solana - Blockchain platform
  • Anchor Anchor Framework - Solana program framework
  • Web3.js @solana/web3.js - Solana JavaScript SDK
  • SPL Token @solana/spl-token - Token operations

Frontend

  • Next.js Next.js 14 - React framework
  • React React 18 - UI library
  • Tailwind CSS Tailwind CSS - Styling
  • Wallet Adapter @solana/wallet-adapter - Wallet integration

Infrastructure

  • Docker Docker - Containerization
  • Redis Redis - Caching & storage (optional)
  • Vitest Vitest - Testing framework

Tools & Libraries

  • Pino Pino - Logging
  • Date-fns date-fns - Date utilities
  • React Hot Toast react-hot-toast - Notifications

πŸ—οΈ Architecture

System Architecture Diagram

UML Sequence Diagram (Swimlanes)

The following Mermaid diagram shows the end-to-end x402 payment flow across swimlanes for Client, Provider, Facilitator, and Solana:

sequenceDiagram
  autonumber
  box Client
    participant C as Client (Web UI / Agent)
  end
  box Provider API
    participant P as Provider API (x402 Guard)
  end
  box Facilitator
    participant F as Facilitator (Verify & Settle)
  end
  box Solana
    participant S as Solana Network
  end

  C->>P: 1) GET /api/data (no X-PAYMENT)
  P-->>C: 2) 402 Payment Required + PaymentRequirements

  note over C: Create x402 Payment Header<br/>- Secure nonce<br/>- Time window<br/>- Authorization payload

  C->>P: 3) GET /api/data with X-PAYMENT
  P->>F: 4) POST /verify { paymentHeader, requirements }
  F-->>P: 5) { isValid: true }

  P->>F: 6) POST /settle { paymentHeader, requirements }
  F->>S: 7) Submit transaction (native/SPL)
  S-->>F: 8) Confirmed (tx hash)
  F-->>P: 9) { success: true, txHash }
  P-->>C: 10) 200 OK + X-PAYMENT-RESPONSE (txHash)
Loading

Alternatively, here is a swimlane-style activity view using Mermaid flowchart subgraphs (lanes):

flowchart LR
  subgraph L1[Client]
    A[Request /api/data] --> B[Receive 402 + Requirements]
    B --> C[Create X-PAYMENT header]
    C --> D[Call /api/data with header]
  end

  subgraph L2[Provider]
    D --> E[Verify with Facilitator]
    E --> G[Settle with Facilitator]
    G --> H[Return 200 + X-PAYMENT-RESPONSE]
  end

  subgraph L3[Facilitator]
    E --> F[Verify Authorization]
    G --> I[Build & Submit Transaction]
  end

  subgraph L4[Solana]
    I --> J[Confirm Transaction]
  end

  J --> H
Loading

Payment Flow Sequence

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Client  β”‚         β”‚ Provider β”‚         β”‚ Facilitator β”‚         β”‚ Solana   β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
     β”‚                   β”‚                      β”‚                     β”‚
     β”‚ 1. GET /api/data  β”‚                      β”‚                     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                      β”‚                     β”‚
     β”‚                   β”‚                      β”‚                     β”‚
     β”‚ 2. 402 Payment    β”‚                      β”‚                     β”‚
     β”‚    Required       β”‚                      β”‚                     β”‚
     β”‚    + Requirements β”‚                      β”‚                     β”‚
     │◄───────────────────                      β”‚                     β”‚
     β”‚                   β”‚                      β”‚                     β”‚
     β”‚ 3. Create Payment β”‚                      β”‚                     β”‚
     β”‚    Authorization  β”‚                      β”‚                     β”‚
     β”‚    (with nonce)   β”‚                      β”‚                     β”‚
     β”‚                   β”‚                      β”‚                     β”‚
     β”‚ 4. POST /api/data β”‚                      β”‚                     β”‚
     β”‚    + X-PAYMENT    β”‚                      β”‚                     β”‚
     β”‚    header         β”‚                      β”‚                     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                      β”‚                     β”‚
     β”‚                   β”‚                      β”‚                     β”‚
     β”‚                   β”‚ 5. POST /verify      β”‚                     β”‚
     β”‚                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                    β”‚
     β”‚                   β”‚                       β”‚                    β”‚
     β”‚                   β”‚ 6. Verify Response   β”‚                     β”‚
     β”‚                   β”‚    {isValid: true}   β”‚                     β”‚
     β”‚                   │◄───────────────────────                    β”‚
     β”‚                   β”‚                       β”‚                    β”‚
     β”‚                   β”‚ 7. POST /settle     β”‚                      β”‚
     β”‚                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚                    β”‚
     β”‚                   β”‚                       β”‚                    β”‚
     β”‚                   β”‚                       β”‚ 8. Create Transactionβ”‚
     β”‚                   β”‚                       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
     β”‚                   β”‚                       β”‚                      β”‚
     β”‚                   β”‚                       β”‚ 9. Transaction Hash  β”‚
     β”‚                   β”‚                       │◄──────────────────────
     β”‚                   β”‚                       β”‚                      β”‚
     β”‚                   β”‚ 10. Settlement Resp  β”‚                       β”‚
     β”‚                   β”‚     {success: true,   β”‚                      β”‚
     β”‚                   β”‚      txHash: "..."}   β”‚                      β”‚
     β”‚                   │◄───────────────────────                      β”‚
     β”‚                   β”‚                       β”‚                      β”‚
     β”‚ 11. 200 OK        β”‚                       β”‚                      β”‚
     β”‚     + X-PAYMENT-  β”‚                       β”‚                      β”‚
     β”‚     RESPONSE      β”‚                       β”‚                      β”‚
     │◄───────────────────                       β”‚                      β”‚
     β”‚                   β”‚                       β”‚                      β”‚

Component Interaction

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Web UI (Next.js)                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚  β”‚   Wallet     β”‚  β”‚   Payment    β”‚  β”‚  Resource    β”‚       β”‚
β”‚  β”‚   Provider   β”‚  β”‚   Modal      β”‚  β”‚   Card       β”‚       β”‚
β”‚  β”‚              β”‚  β”‚              β”‚  β”‚              β”‚       β”‚
β”‚  β”‚  β€’ Connect   β”‚  β”‚  β€’ Show     β”‚  β”‚  β€’ Display    β”‚       β”‚
β”‚  β”‚  β€’ Sign      β”‚  β”‚    Amount    β”‚  β”‚    Info      β”‚       β”‚
β”‚  β”‚  β€’ State     β”‚  β”‚  β€’ Execute   β”‚  β”‚  β€’ Trigger   β”‚       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ HTTP
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Provider API Service                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚              x402 Guard Middleware                 β”‚     β”‚
β”‚  β”‚                                                    β”‚     β”‚
β”‚  β”‚  1. Check X-PAYMENT header                         β”‚     β”‚
β”‚  β”‚  2. If missing β†’ Return 402                        β”‚     β”‚
β”‚  β”‚  3. If present β†’ Verify with Facilitator           β”‚     β”‚
β”‚  β”‚  4. If valid β†’ Settle with Facilitator             β”‚     β”‚
β”‚  β”‚  5. If settled β†’ Allow request to proceed          β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                            β”‚                                β”‚
β”‚                            β”‚ POST /verify, /settle          β”‚
β”‚                            β–Ό                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚
                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Facilitator Service                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚              Verification Engine                   β”‚     β”‚
β”‚  β”‚                                                    β”‚     β”‚
β”‚  β”‚  β€’ Parse payment header                            β”‚     β”‚
β”‚  β”‚  β€’ Validate signature                              β”‚     β”‚
β”‚  β”‚  β€’ Check nonce (replay protection)                 β”‚     β”‚
β”‚  β”‚  β€’ Validate time window                            β”‚     β”‚
β”‚  β”‚  β€’ Verify amount & recipient                       β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                            β”‚                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚              Settlement Engine                     β”‚     β”‚
β”‚  β”‚                                                    β”‚     β”‚
β”‚  β”‚  β€’ Create Solana transaction                       β”‚     β”‚
β”‚  β”‚  β€’ Sign with fee payer                             β”‚     β”‚
β”‚  β”‚  β€’ Submit to blockchain                            β”‚     β”‚
β”‚  β”‚  β€’ Wait for confirmation                           β”‚     β”‚
β”‚  β”‚  β€’ Return transaction hash                         β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                            β”‚                                β”‚
β”‚                            β”‚ RPC                            β”‚
β”‚                            β–Ό                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚
                            β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Solana     β”‚
                    β”‚  Blockchain  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js Node.js 18+ and npm/pnpm
  • Solana CLI Solana CLI (optional, for contract deployment)
  • Docker Docker (optional, for containerized deployment)

Installation

# Clone the repository
git clone https://github.com/yourusername/microapi-hub.git
cd microapi-hub

# Install dependencies
npm install --workspaces

Start Services

1. Facilitator Service

cd services/facilitator

# Create .env file
cat > .env << EOF
PORT=8787
NETWORK=devnet
RPC_URL=https://api.devnet.solana.com
FEE_PAYER_SECRET=  # Optional: base58-encoded keypair
SETTLEMENT_MODE=native
DEMO_MODE=true
EOF

# Start facilitator
npm run dev

2. Provider API

cd services/provider-api

# Create .env file
cat > .env << EOF
PORT=8080
PAY_TO_PUBKEY=YOUR_SOLANA_PUBKEY
USDC_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
FACILITATOR_URL=http://localhost:8787
EOF

# Start provider API
npm run dev

3. Web UI

cd clients/web

# Create .env.local file
cat > .env.local << EOF
NEXT_PUBLIC_PROVIDER_DISCOVERY_URL=http://localhost:8080/.well-known/x402
EOF

# Start web UI
npm run dev

Access Application


πŸ”§ Services

Facilitator Service

Payment verification and on-chain settlement service.

Endpoints:

  • POST /verify - Verify payment authorization
  • POST /settle - Settle payment on-chain
  • GET /health - Health check
  • GET /supported - Supported payment schemes

Key Features:

  • βœ… Signature verification
  • βœ… Nonce replay protection
  • βœ… Time window validation
  • βœ… Native SOL and SPL token settlement
  • βœ… Auto-funding on devnet
  • βœ… Redis/file-based storage

Provider API

API server with x402 payment protection.

Endpoints:

  • GET /api/data - Protected endpoint (example)
  • GET /.well-known/x402 - Discovery endpoint
  • GET /health - Health check

Key Features:

  • βœ… 402 Payment Required responses
  • βœ… Payment verification integration
  • βœ… Automatic settlement
  • βœ… Discovery endpoint
  • βœ… Resource protection middleware

Web UI

Next.js application with wallet integration.

Features:

  • βœ… Wallet connection (Phantom, Solflare)
  • βœ… Payment modal with real-time status
  • βœ… Resource discovery
  • βœ… Transaction history
  • βœ… Receipt viewer
  • βœ… Code examples
  • βœ… Comprehensive documentation

πŸ“š Documentation

Core Documentation

In-App Documentation


πŸ’» Development

Project Structure

microapi-hub/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ facilitator/          # Payment verification & settlement
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts      # Main facilitator service
β”‚   β”‚   β”‚   β”œβ”€β”€ config.ts     # Configuration management
β”‚   β”‚   β”‚   β”œβ”€β”€ errors.ts     # Error handling
β”‚   β”‚   β”‚   └── registry.ts   # Registry client
β”‚   β”‚   └── package.json
β”‚   └── provider-api/         # Protected API server
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ index.ts      # Main provider service
β”‚       β”‚   └── config.ts     # Configuration
β”‚       └── package.json
β”œβ”€β”€ clients/
β”‚   β”œβ”€β”€ web/                  # Next.js web UI
β”‚   β”‚   β”œβ”€β”€ app/              # Next.js app router
β”‚   β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ lib/               # Utilities
β”‚   β”‚   └── package.json
β”‚   └── agent-demo/            # Example client
β”œβ”€β”€ contracts/
β”‚   └── registry/             # Solana Anchor program
β”‚       └── programs/
β”‚           └── registry/
β”‚               └── src/
β”‚                   └── lib.rs # Registry contract
β”œβ”€β”€ shared/
β”‚   └── types/                 # Shared TypeScript types
β”‚       β”œβ”€β”€ x402.ts           # x402 protocol types
β”‚       β”œβ”€β”€ errors.ts         # Error types
β”‚       └── registry.ts      # Registry types
β”œβ”€β”€ docs/                      # Documentation
β”‚   β”œβ”€β”€ API.md
β”‚   └── DEVELOPER.md
β”œβ”€β”€ infra/                      # Infrastructure
β”‚   └── docker-compose.yml
└── x402/                       # x402 protocol library

Running Tests

# Run all tests
npm test

# Run E2E tests
npm run e2e

Building

# Build all services
npm run build

Docker

# Start all services with Docker Compose
cd infra
docker-compose up

πŸ† Hackathon Submission

Requirements Met

βœ… x402 Protocol Integration: Full specification implementation
βœ… Solana Integration: Deployed to devnet, mainnet-ready
βœ… Open Source: All code on GitHub
βœ… Demo Video: 3-minute demonstration
βœ… Documentation: Comprehensive setup and usage guides

Demo Video

See HACKATHON.md for demo video script and submission details.

What Makes This Special

  1. Complete Stack: End-to-end implementation from facilitator to UI
  2. Production-Ready: Error handling, validation, logging, testing
  3. Developer-Friendly: Comprehensive docs, code examples, easy integration
  4. On-Chain Registry: Decentralized API discovery
  5. Multi-Language: Support for TypeScript, Python, Go
  6. Wallet Integration: Seamless payment UX with wallet adapters

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Write tests for new features
  • Update documentation
  • Follow the existing code style
  • Ensure all tests pass

πŸ“ License

This project is open source. See LICENSE file for details.


πŸ™ Acknowledgments

  • Coinbase for the x402 protocol specification
  • Solana Foundation for the hackathon
  • All open-source contributors

πŸ“ž Support


🚧 Roadmap

  • Mainnet deployment
  • Multi-chain support (EVM)
  • Advanced payment schemes
  • Analytics dashboard
  • Webhook notifications
  • Client SDK package
  • Rate limiting per client
  • Usage analytics

Built with ❀️ for the Solana X402 Hackathon

⬆ Back to Top

About

Complete x402 (Solana) payment protocol implementation for API monetization. Built for Solana X402 Hackathon.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published