CyberNanoPay — x402 API
x402-compatible HTTP nano-payment gateway. Sellers integrate this gateway, and buyers pay to access resources via the Payment-Signature header.
Flow
- Client requests a protected resource
- Gateway returns
402 Payment Required+ payment requirements - Client signs the authorization
- Client retries the request with the
Payment-Signatureheader - Gateway verifies the signature via TEE → grants access
402 Response Format
When requesting a protected resource without the Payment-Signature header:
HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: base64(requirements)Decoded:
{
"x402Version": 2,
"accepts": [
{
"scheme": "ton-nanopay",
"network": "ton-mainnet",
"amount": "1000",
"to": "seller-address",
"asset": "USDT",
"extra": {
"name": "CyberNanoPay",
"verifyingContract": "gateway-address",
"teeEndpoint": "http://tee-url"
}
}
]
}Verify Payment
POST /verify
Used for direct integration; forwards authorization data to TEE for verification.
{
"from": "buyer-address",
"to": "seller-address",
"amount": "1000",
"signature": "..."
}Query Balance
GET /balance/{address}
GET /balance/UQBxxx...Statistics
GET /stats
Returns gateway statistics.
TEE Attestation
GET /attestation
Returns TEE environment attestation, which sellers can use to verify the gateway is running in a trusted execution environment.
Policy Management
Set Policy
POST /policy
{
"address": "seller-address",
"maxAmount": "10000",
"rateLimit": 100
}Query Policy
GET /policy/{address}
Approval Status
GET /approvals
Returns the HITL (Human-in-the-Loop) approval queue.
Integration Example
Use the requirePayment middleware to protect routes:
import { requirePayment } from "cyber-nano-pay";
app.get(
"/premium-data",
requirePayment({ amount: "1000", to: "seller-address" }),
(c) => {
const payment = c.get("payment");
return c.json({
data: "Premium content",
confirmationId: payment.confirmationId,
});
}
);