Archive

Agent Pays for an API

An autonomous agent discovers a paywall and pays it on Sui, retired with s402

TypeScriptSuiHTTP 402AI AgentHono

Agent Pays for an API

I retired s402 in September 2026. It was my HTTP 402 payment protocol for agents on Sui, and x402 has since become the industry standard. For new work, use x402.

The companion proof for s402 — not the protocol, but an agent actually using it. An autonomous agent calls a paywalled API, gets back 402 Payment Required, reads a price it never knew, signs a Sui payment, retries, and receives the data. No API keys. No human in the loop.

What happens

  1. Agent calls a free endpoint → data, no payment.
  2. Agent calls a premium endpoint → 402 + machine-readable s402 terms (exact, amount, asset, payTo). It discovers the price.
  3. The agent's s402 client signs a Sui transaction and retries with an X-PAYMENT header.
  4. The server settles on Sui testnet and returns 200 + data + a receipt carrying the on-chain tx digest.

The server holds no key — it only broadcasts the agent's signed transaction. Trustless by construction.

Run it

pnpm install --ignore-workspace
export SUI_TESTNET_PRIVATE_KEY=…   # a funded testnet wallet
pnpm exec tsx demo.ts

Demo

Terminal recording lands here — every premium response is backed by a real Sui testnet transaction, with Suiscan links printed in the run.

Proof

  • npm: s402 — the protocol, v0.9.0, deprecated since September 2026.
  • Built on @sweefi/sui.
  • Verified: server + 402 handshake observed live; full settlement issues real testnet transactions.
One instance of → the agent-to-human handoff

Building in this space, or want to compare notes?

Get in touch