Skip to content
 
 

Repository files navigation


Logo

C402 Protocol Gateway

A decentralized pay-per-request HTTP 402 proxy billing gateway for Cardano microservices and AI inferences.
Explore the docs »

Video Demo · Report Bug · Request Feature


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

C402 is an implementation of the HTTP 402 (Payment Required) standard designed for the Cardano blockchain ecosystem. It acts as an intercepting proxy billing gateway that guards pay-per-request API resources, such as machine learning completions or web scraper outputs, demanding micropayments (Lovelaces) before serving client queries.

Key capabilities:

  • Decentralized Proxy Interception: Instantly responds with HTTP 402 Payment Required headers containing payout addresses, pricing models, and signature challenge references.
  • Double-Spend Mitigation: In-memory tracking lists protect developers from replay attacks and multiple reuse of transaction proofs.
  • Preprod Sync Verification: Directly queries Cardano ledger mempool state to authorize endpoint execution in milliseconds.
  • SAT Satisfaction Audio Toggle: satisfies the Buddhsentripathi-style Centered glassmorphic design theme with Web Audio API click sound toggles.

Built With

  • Vite & React 18: Lightweight SPA dashboard interface.
  • Node.js & Express: Gateway proxy intercepting middleware.
  • Aiken: Cardano smart contracts validator.
  • Framer Motion & Lucide Icons: Responsive animation layers.

(back to top)

Getting Started

Follow these steps to run the gateway and sandbox playground locally.

Prerequisites

  • Node.js v18 or later.
  • npm or yarn.
  • Lace Wallet Chrome Extension configured for the Cardano Preprod testnet.

Installation

  1. Clone the repository:
    git clone https://github.com/Premkumar1845/ProofPair.git
    cd ProofPair
  2. Install dependencies:
    npm install
  3. Spin up both servers:
    • Run the Express server (backend/):
      npm run start
    • Run the Vite dev server (root/):
      npm run dev

(back to top)

Usage

  1. Open the website at http://localhost:5174/ and navigate to the Sandbox Playground.
  2. Select Llama-3 Coder API and trigger Call Protected API to fetch the 402 challenge.
  3. Paste a Cerebras API Key into the configuration panel to unlock live Llama-3 completions.
  4. Connect a Cardano preprod-configured Lace wallet and click Sign Payment.
  5. Approve the signature payload in the Lace extension.
  6. Click Call Protected API again to submit the transaction token and unlock the code generation response.
  7. Copy the following valid Preprod testing transaction hash:
    2dc9ad62dc9ad62dc9ad62dc9ad62dc9ad62dc9ad62dc9ad62dc9ad62dc9ad62c402
    

(back to top)

Roadmap

  • Configure modular Vite React frontend router
  • Implement CIP-30 connection and CBOR-to-Bech32 decoders
  • Deploy Node/Express gateway proxy with 402 headers support
  • Set up double-spend caching replay verification list
  • Integrate live Cerebras Llama-3 code generations
  • Add dynamic Blockfrost testnet block height checks
  • Implement full client-side ledger transaction serialization

See the open issues for a full list of proposed features and known bugs.

(back to top)

Contributing

Contributions are welcome. Please adhere to these guidelines:

  1. Fork the Project.
  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.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Hemanth - hemanthme.in
Prem Kumar - @Premkumar1845

Project Link: https://github.com/Premkumar1845/ProofPair

(back to top)

Acknowledgments

(back to top)

About

C402 Protocol is an open-source HTTP 402 payment gateway for Cardano that enables pay-per-request API monetization using native ADA micropayments. It verifies on-chain payments, prevents replay attacks, and lets developers monetize APIs without subscriptions, API keys, or prepaid credits.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages