px402
public devnet / v0.1.1

Payment happened.
Intent stayed private.

px402 is an HTTP payment layer for AI agents. It settles USDC through MagicBlock’s private rail so the public chain records payment without revealing which API received it.

$ pnpm add @px402/client
trace / px-000402settlement verified
GET
request
402
challenge
TEE
redact
200
response
public ledger
sender
3wBh...AiA
mint
USDC
amount
0.01
observer cannot resolve
recipient
[ REDACTED ]
api route
[ REDACTED ]
revenue map
[ REDACTED ]

Settlement remains real. The link between payer intent and API recipient does not reach the public chain.

privacy proof

The chain sees settlement. Not intent.

An outside observer can prove USDC moved. They cannot connect that payment to the API, recipient wallet, or server revenue map.

The privacy claim is specific: px402 breaks the public link between payment and API consumption.
public on solana
  • 01Sender wallet
  • 02Mint (USDC)
  • 03Amount (micro-USDC)
hidden inside the tee
  • 01[ RECIPIENT WALLET REDACTED ]
  • 02[ WHICH API WAS PAID REDACTED ]
  • 03[ SERVER'S REVENUE MAPPING REDACTED ]
observer result / settlement confirmedrecipient unresolved
protocol trace

One request. Six verifiable steps.

px402 keeps the familiar HTTP payment loop. The private rail changes what settlement exposes, not how the client handles a 402.

  1. 01

    Request

    Agent asks the protected API for data.

    GET /data
  2. 02

    Challenge

    Server returns price, destination token, and expiry.

    402
  3. 03

    Settle

    Client signs a USDC transfer through MagicBlock.

    private rail
  4. 04

    Redact

    The TEE resolves the recipient away from public view.

    TEE
  5. 05

    Verify

    Subscriber matches the settlement by clientRefId.

    base chain
  6. 06

    Respond

    The same request retries and receives the paid result.

    200 OK
Open the full protocol sequence
Detailed px402 protocol sequence from request through private settlement and response
quickstart

Choose a side. Add one package.

API providers add a framework adapter. Agents replace fetch. MCP users run the server directly. Production configuration stays explicit and out of the landing-page happy path.

01 / API providerserver
server.ts
import { Hono } from "hono";import { px402 } from "@px402/hono"; const app = new Hono();app.use(px402(paymentConfig));app.get("/api/sentiment", handler);

pnpm add @px402/hono @px402/core

02 / Agent builderclient
agent.ts
import { Px402Client } from "@px402/client"; const client = new Px402Client({ wallet, mint });const res = await client.fetch("https://api.px402.allensaji.dev/api/sentiment?token=SOL");const data = await res.json();
03 / MCP user
$ npx @px402/mcpMCP reference
verified devnet

A 402 you can inspect.

single call
~4s
30 concurrent
96.7%

The API data is illustrative. The payment path is not. Each route returns a real 402, settles USDC, and serves data only after the retry.

route
price
/api/sentiment?token=SOL
0.01 USDC
bullish / bearish / neutral + confidence
/api/whales?min=100000
0.02 USDC
recent large transfers
/api/risk?address=...
0.03 USDC
wallet risk score + signal flags
recorded trace / clean devnet
01
Request challenged
HTTP 402
02
Private settlement
USDC / TEE
03
Retry accepted
HTTP 200
$ curl -i https://api.px402.allensaji.dev/api/sentiment?token=SOL
HTTP/1.1 402 Payment Required
X-Payment-Amount: 10000
X-Payment-Token: v1.eyJ...
package index

Install only what your role needs.

The protocol stays modular. Providers choose one framework adapter. Agent builders use the client or MCP server. Core carries the shared verification machinery.

01
@px402/core
protocol
HMAC tokens, base-chain polling subscriber, framework-agnostic decide().
02
@px402/hono
provider
Hono middleware.
03
@px402/express
provider
Express middleware.
04
@px402/next
provider
Next.js App Router HOC.
05
@px402/client
agent
fetch wrapper. deposit / transfer / balance / privateBalance.
06
@px402/mcp
agent tool
MCP server. px402_fetch, px402_balance.

npm package indexsource repository

threat model

Know the boundary before you ship.

px402 narrows what a public observer can link. It does not make the transfer disappear, remove the TEE trust assumption, or turn devnet software into production infrastructure.

Public
  • 01Sender wallet
  • 02USDC mint
  • 03Per-call amount
Hidden
  • 01Recipient wallet
  • 02API route
  • 03Revenue mapping
Trusted
  • 01MagicBlock TEE
  • 02Validator execution
  • 03Subscriber configuration
01

Per-call amount is on-chain.

If only one server charges 0.073 USDC for one specific endpoint, the amount itself is a fingerprint.

02

Anonymity-set size matters.

At launch, you are alone on the validator. Privacy comes online with volume.

03

Not a drop-in x402 facilitator.

Migrating from canonical x402-svm is a rewrite, not a config swap.

04

Pre-alpha. Devnet only.

~4s single-call latency. 96.7% success at 30 concurrent. Numbers from a clean devnet run.

05

TEE trust assumption.

MagicBlock's TEE has the recipient mapping. If the TEE is compromised, unlinkability is revealed retroactively.

These are current constraints, not hidden footnotes. Read the README for the full list.