Getting Started
Quick Start
Wrap any FastAPI route with @PaidEndpoint and it will require x402 payment.
python
from fastapi import FastAPI, Request
from hack.toolkit import PaidEndpoint
app = FastAPI()
@app.post("/api/premium-query")
@PaidEndpoint(price="0.5 HBAR")
async def premium_query(request: Request):
return {"result": "paid access granted"}What happens
1. Client calls the endpoint with no proof → HACK returns HTTP 402 with a quote. 2. Client sends HBAR to the receiver account. 3. Client retries with X-Quote-Id and X-Payment-Token headers. 4. HACK verifies via Mirror Node, opens a grant window, and returns 200 OK.
Every step is auditable via HCS receipts.