x402 · bitcoin-onchain scheme

Bitcoin payments for
autonomous agents

A lightweight HTTP facilitator that verifies and settles Bitcoin on-chain payments following the x402 protocol. No custodians. No accounts. Just transactions.

Try it live View source
checking…
Service status
bitcoin-onchain
Scheme
1
Min confirmations
Chain data
SQLite
Replay protection

How it works

Three steps from payment claim to settled resource access

Step 01

Client builds a payment

The client sends a Bitcoin transaction on-chain and encodes the txid, recipient address, and amount (in sats) as a Base64 JSON header: X-Payment.

Step 02

Facilitator verifies

POST /verify decodes the header, hits the Blockstream API to confirm the tx exists on-chain with sufficient confirmations and the correct output amount. Replayed txids are rejected immediately.

Step 03

Settle & grant access

POST /settle re-verifies and permanently records the txid in SQLite. A signed Payment-Response header is returned. The resource server grants access.


API reference

Base URL: https://x402-bitcoin.cdnsoft.net

GET /health Service liveness check
// Response 200
{
  "status": "ok",
  "service": "x402-bitcoin",
  "scheme": "bitcoin-onchain"
}
POST /verify Validate a payment claim (read-only)

Request header

FieldTypeDescription
X-PaymentBase64Base64-encoded JSON payload (see below)

Payload fields

FieldTypeDescription
txidstringBitcoin transaction hex ID required
recipientstringBitcoin address receiving payment required
amountSatsintegerExpected output value in satoshis required
schemestring"bitcoin-onchain" (optional)
resourcestringURL being accessed (optional)
noncestringBinding nonce (optional)

Response

// 200 — valid
{
  "valid": true,
  "txid": "abc123…",
  "recipient": "148G6…",
  "amountSats": 10000,
  "confirmations": 3,
  "scheme": "bitcoin-onchain"
}

// 402 — invalid
{
  "valid": false,
  "error": "Insufficient confirmations",
  "code": "UNCONFIRMED",
  "confirmations": 0
}

Error codes

CodeHTTPMeaning
TX_NOT_FOUND402txid not on-chain
UNCONFIRMED402not enough confirmations
AMOUNT_MISMATCH402wrong amount or address
REPLAY402txid already settled
NETWORK_ERROR500Blockstream API failure
POST /settle Verify + record payment (write)

Request header

FieldTypeDescription
X-PaymentBase64Same payload as /verify

Settle re-runs the full /verify check before writing. If verification fails, nothing is recorded. Calling /settle twice with the same txid returns REPLAY on the second call.

Response

// 200 — settled
{
  "settled": true,
  "txid": "abc123…",
  "recipient": "148G6…",
  "amountSats": 10000,
  "settledAt": "2026-03-16T01:00:00.000Z",
  "scheme": "bitcoin-onchain"
}
// Response header:
Payment-Response: <base64 receipt>

// 402 — not settled
{
  "settled": false,
  "error": "Transaction already settled",
  "code": "REPLAY"
}

Live tester

Hit the real API — use a confirmed mainnet tx from blockstream.info

Payment Payload

Find a real tx on blockstream.info — copy the txid, recipient address, and exact output value in sats. The tx must be confirmed.

POST /verify verify

Checks the tx on-chain via Blockstream. Returns valid/invalid without recording anything.

— response will appear here —

POST /settle settle

Re-verifies then records the txid in SQLite. Subsequent calls with the same txid are rejected.

— response will appear here —