diff --git a/web/docs.html b/web/docs.html new file mode 100644 index 0000000..fd13218 --- /dev/null +++ b/web/docs.html @@ -0,0 +1,916 @@ + + + + + + switchboard — backend reference + + + + + + + + + +
+ + kcolbchain/switchboard + + +
+ +
+ +
+

backend reference.

+

+ Module-by-module API, examples, and current status. Switchboard is a + Python library; install via pip install switchboard[pq]. + Token-agnostic, chain-agnostic, post-quantum by default. +

+
+ +
+ + + + +
+ + +
+
+

x402_middleware

+ shipped +
+
switchboard/x402_middleware.py
+ +
+

+ Server-side HTTP 402 gate. Drop into FastAPI or Flask, + point it at a treasury address and an accepted asset/network, and any + route you list is paywalled. The middleware verifies the caller's + X-PAYMENT envelope, emits the standard accepts[] + response on first hit, and passes verified requests through. +

+

+ The wire format is the open x402 + spec; the on-chain settlement is whichever rail the route accepts. + Switchboard makes no assumption about which token or chain — the + middleware's constructor is the place that decides. +

+
+ +

parameters

+ + + + + + + + + + +
nametypenote
pay_tostrtreasury address that receives payment
assetstrtoken contract address (USDC, USDT, custom — token-agnostic)
networkstrbase-sepolia, base-mainnet, ethereum, avalanche-c, tron, lux-c
pricestramount in token's smallest unit per request
pathslist[str]routes to gate. Globs supported.
accepted_algslist[str]signature algs to accept. Defaults: ecdsa-secp256k1 + dilithium3.
+ +

example

+
from fastapi import FastAPI
+from switchboard.x402_middleware import X402Middleware
+
+app = FastAPI()
+app.add_middleware(
+    X402Middleware,
+    pay_to="0xYourTreasury...",
+    asset="0x036CbD53842c5426634e7929541eC2318f3dCF7e",  # USDC on Base Sepolia
+    network="base-sepolia",
+    price="1000",                  # 0.001 USDC per call
+    paths=["/agent-only"],
+)
+
+@app.get("/agent-only")
+def agent_only():
+    return {"ok": True}
+ + +
+ + +
+
+

zap_transport

+ in PR +
+
switchboard/zap_transport.py
+ +
+

+ Binary wire format for PaymentOffer and + PaymentProof over luxfi/zap. + Zero-allocation; roughly an order of magnitude smaller than JSON. The + right choice when two agents exchange thousands of payment messages a + second — for one-off settlement, the JSON envelope is fine. +

+

+ Switchboard is the first production consumer of zap_py, + the Python binding for ZAP. The wire schema is shared with + payment_protocol; ZAP is just an + alternative encoding. +

+
+ +

example

+
from switchboard.zap_transport import ZapTransport
+from switchboard import PaymentOffer
+
+t = ZapTransport(endpoint="zap://peer.example:9601")
+
+offer = PaymentOffer(
+    pay_to="0x...", asset="USDC",
+    amount="1000", network="base-sepolia",
+)
+
+# Send: serializes to ZAP binary, single syscall, no GC pressure
+proof = await t.request(offer)
+ + +
+ + +
+
+

payment_protocol

+ shipped +
+
src/payment_protocol.py
+ +
+

+ The shared schema for PaymentOffer and + PaymentProof. Every rail (x402 over HTTP, ZAP over + sockets, on-chain via AgentEscrow) speaks variants of these two + messages. The protocol module owns the canonical form and the + transcript hash used by signing. +

+

+ Token-agnostic: asset is whatever the two parties agree + on. Chain-agnostic: network selects an adapter at the + consumer layer. PQ-ready: signature_alg + signature + are first-class fields, not optional add-ons. +

+
+ +

PaymentOffer

+
@dataclass
+class PaymentOffer:
+    pay_to:        str
+    asset:         str            # token contract or chain-native symbol
+    network:       str            # base-sepolia, tron, avalanche-c, lux-c, ...
+    amount:        str            # in token's smallest unit
+    nonce:         bytes          # 16 random bytes
+    deadline:      int            # unix seconds
+    signature_alg: str = "dilithium3"
+    signature:     bytes = b""
+ +

PaymentProof

+
@dataclass
+class PaymentProof:
+    offer_hash:    bytes          # transcript hash of the accepted offer
+    tx_hash:       str            # on-chain tx (empty for off-chain rails)
+    block:         int | None
+    signature_alg: str = "dilithium3"
+    signature:     bytes = b""
+ + +
+ + +
+
+

AgentEscrow.sol

+ shipped + EIP draft +
+
contracts/AgentEscrow.sol
+ +
+

+ Trustless escrow for agent-to-agent payments. Caller locks funds with + a deadline and a challenge period; provider claims on delivery; either + side can dispute inside the challenge window. Native-ETH variant has + no token wrapper at all — pay, claim, refund all happen in native ETH. +

+

+ The Python client (src/payment_protocol.py) wraps the + contract in a clean async interface; the CLI ships the same flows for + shell use. The native-ETH variant is formalized as a Standards-Track + ERC (#50). +

+
+ +

solidity surface

+
function deposit(address provider, uint256 deadline, uint256 challenge)
+    external payable returns (uint256 escrowId);
+
+function claim(uint256 escrowId, bytes calldata receipt) external;
+function dispute(uint256 escrowId, bytes calldata evidence) external;
+function refund(uint256 escrowId) external; // after deadline + challenge
+function cancelMutual(uint256 escrowId, bytes calldata peerSig) external;
+ +

python flow

+
from switchboard.escrow import AgentEscrow
+
+esc = AgentEscrow(network="base-sepolia", contract="0x...")
+
+# caller: lock 0.01 ETH for the provider, 1 hour deadline + 1 hour challenge
+escrow_id = await esc.deposit(
+    provider="0xPeer...",
+    value=eth("0.01"),
+    deadline=hours("1"),
+    challenge=hours("1"),
+)
+
+# provider: claim with receipt
+await esc.claim(escrow_id, receipt=signed_receipt)
+ + +
+ + +
+ +
switchboard/gas_budget.py · switchboard/gas_tracker.py
+ +
+

+ Hard budgets — per-hour, per-day, per-network — that an agent cannot + exceed even if its policy goes haywire. gas_tracker + records what's been spent; gas_budget rejects the next + tx if it would breach the budget. Closes the #1 footgun of autonomous + on-chain agents: runaway loops burning their own treasury. +

+

+ Tracker is in-memory by default but takes a backing store (SQLite, + Redis) for multi-process agents. +

+
+ +

example

+
from switchboard.gas_budget import GasBudget
+from switchboard.gas_tracker import GasTracker
+
+tracker = GasTracker()                              # in-memory
+budget  = GasBudget(
+    tracker=tracker,
+    per_hour=gwei("500_000"),
+    per_day =gwei("5_000_000"),
+)
+
+if not budget.would_allow(network="base-sepolia", est_gas=tx_gas):
+    raise BudgetExceeded()
+
+tracker.record(network="base-sepolia", used=tx_gas)
+ + +
+ + +
+
+

nonce_manager

+ shipped +
+
switchboard/nonce_manager.py
+ +
+

+ Client-side nonce manager with reorg protection. Keeps a local view + of the next nonce per (address, network); on reorg, rolls back. The + piece every shipping autonomous agent eventually has to write — + written once, here, with the edge cases (replacement tx, stuck + mempool, multi-network parallelism) handled. +

+
+ +

example

+
from switchboard.nonce_manager import NonceManager
+
+nm = NonceManager(rpc=rpc_client)
+
+async with nm.reserve(address, network="base-sepolia") as n:
+    tx = build_tx(nonce=n, ...)
+    await rpc.send(tx)
+    # NonceManager auto-commits on success, rolls back on reorg or send error
+ + +
+ + +
+
+

pq · post-quantum

+ north star + PQ-2 shipped +
+
switchboard/pq.py · switchboard/pq_keys.py
+ +
+

+ Wrapper over liboqs + providing Dilithium / Falcon / SPHINCS+ signatures with a single + API. Default algorithm is Dilithium3 (NIST level 3, balanced + speed/size). Algorithm is carried explicitly in every + PaymentOffer and PaymentProof; switchboard + never has to guess what to verify with. +

+

+ Install with pip install switchboard[pq] — the [pq] + extra pulls liboqs-python. The wire schema for + signature_alg + signature is fixed in + PQ-5. +

+
+ +

example

+
from switchboard.pq        import sign, verify, ALG_DILITHIUM3
+from switchboard.pq_keys   import generate, load
+
+# once, off-thread: generate and save a PQ keypair
+kp = generate(alg=ALG_DILITHIUM3)
+kp.save("./agent.pq.json")
+
+# at runtime: sign an offer's canonical transcript
+kp = load("./agent.pq.json")
+sig = sign(offer.canonical(), kp)
+
+# peer side: verify
+assert verify(offer.canonical(), sig, kp.public, alg=offer.signature_alg)
+ + +
+ + +
+
+

a2a_x402 adapter

+ shipped +
+
switchboard/adapters/a2a_x402.py
+ +
+

+ Adapter between Google's A2A (Agent-to-Agent) framework and the + open x402 protocol. Lets an A2A agent get paid in x402; lets an + x402 caller invoke an A2A agent. Translates message envelopes, + preserves the PQ signature, and respects the gas budget on both + sides. +

+
+ +

example

+
from switchboard.adapters.a2a_x402 import A2AOverX402
+
+bridge = A2AOverX402(
+    a2a_endpoint="https://my-agent.example/a2a",
+    x402_pay_to="0x...",
+    asset="USDC", network="base-sepolia",
+)
+
+result = await bridge.invoke(task=task, max_payment=usdc("0.05"))
+ + +
+ + +
+
+

x402.server

+ shipped +
+
switchboard/x402/server.py
+
+

+ Standalone HTTP 402 server. The middleware variant + (x402_middleware) wraps an existing + FastAPI/Flask app; this module ships a complete server you can run + as its own process — useful when the paid endpoint isn't part of a + larger application. +

+
+ +
+ + +
+
+

mpp.session

+ shipped +
+
switchboard/mpp/session.py
+
+

+ Multi-party payment sessions. Open a streaming channel between two + agents under a budget cap; stream micro-pays as work is performed; + settle on close. The Tempo / Stripe-style rail for long-running + agent collaborations. +

+
+ +
+ + +
+
+

mpc_wallet

+ shipped +
+
switchboard/mpc_wallet.py
+
+

+ Multi-party-computation wallet — threshold signatures across an + agent fleet, so no single machine holds the spending key. Useful + for high-value treasuries that have to survive any one node being + compromised. +

+
+ +
+ + +
+
+

OracleAggregator

+ shipped +
+
contracts/IOracleAggregator.sol · AgentEscrow.releaseByAttestation()
+
+

+ Oracle-mediated escrow release. A designated oracle aggregator + attests that delivery occurred; the contract releases funds without + requiring on-chain dispute resolution. The fast path for the common + case (provider delivers, no contest). +

+
+ +
+ + +
+
+

adapters/lucidly

+ shipped +
+
switchboard/adapters/lucidly.py
+
+

+ syUSD auto-park for idle agent balances. Any USDC the agent isn't + actively using gets parked into Lucidly's yield-bearing syUSD + position by default, then pulled back automatically when the agent + needs to make a payment. Idle treasury earns yield without manual + management. +

+
+ +
+ + +
+
+

multi-chain settlement

+ design v0.1 +
+
docs/multi-chain-settlement.md · contracts forthcoming
+ +
+

+ The chain-agnostic settlement surface. Agents transact on whichever + chain fits the job (TRON for sub-cent fees, AVAX for liquidity, + Base for USDC, ETH for native escrow); switchboard adapters present + a uniform interface so payment code never branches per-chain. +

+

+ Chosen path: notary attestation for v1 (low-cost, + production-ready today), upgradable in-place to ZK-relay for v2 + (Groth16 proofs on LUX, trustless cross-chain verification). TRON + finality at 19 blocks, Avalanche C-Chain at 5, LUX at 2. +

+

+ Full spec — envelope schema, per-chain verification paths, finality + tables, and considerations — in + + docs/multi-chain-settlement.md. Resolves + #59. +

+
+ +

envelope schema

+
envelope {
+  source_chain:      string    // CAIP-2 (e.g. "eip155:1", "tron:mainnet")
+  destination_chain: string
+  request_id:        string    // UUIDv4
+  payload:           bytes     // serialized PaymentRequest / PaymentProof
+  source_block:      uint64
+  source_tx:         bytes32
+  attestation:       bytes     // notary signature or ZK proof
+  attestation_type:  uint8     // 0x01 = notary (ECDSA), 0x02 = ZK (Groth16)
+}
+ + +
+ +
+
+
+ + + + + diff --git a/web/index.html b/web/index.html index 33e57ed..c817fe7 100644 --- a/web/index.html +++ b/web/index.html @@ -1,422 +1,1094 @@ - - -switchboard — agent payments infrastructure - - + + + switchboard — programmable payments for agents + + + + + + -
-
-

switchboard. agent payments infrastructure

-

Agent wallets, gas budgets, agent-to-agent escrow. Compatible with the open agent-payment rails of 2026: x402, MPP, AP2, Circle Nanopayments.

-
-
+
+ + kcolbchain/switchboard + +
+ source ↗ +
-
+
-

Protocol flow

-
- - - - - -
+ +
+

programmable payments for agents.

+

+ One Python library, one contract suite, one binary wire — so two AI agents + from different teams can pay each other for work, without a human in the loop. +

+
+ post-quantum + chain-agnostic + token-agnostic + agent-native + HTTP 402 · MPP · AP2 · ZAP wire +
+
-
-
-
-

-
-
+ +
+
+

at a glance

+ v0.1.1 · active +
+
+
+
modules
+
12
+
11 shipped, 1 in PR
+
+
+
PRs merged
+
30+
+
x402 · MPP · MPC · PQ · escrow · oracle
+
+
+
lab scenes
+
16
+
animated, fork-and-extend
-
-

Steps

-
    +
    +
    chains targeted
    +
    5
    +
    LUX · ETH · Base · AVAX · TRON
    +
    + + +
    +
    +

    modules

    + one library, twelve pieces +
    +

    + Each module ships independently and is composable with the rest. Pick the ones + you need — gate an HTTP route, hold funds in escrow, sign a payment with a + post-quantum key, or write your own adapter. The contract surface is small, + the wire format is open, and every piece is auditable. +

    + +
    -
    -
    - - - - - - - +
    +
    +

    x402_middleware

    + shipped +
    +
    + Server-side HTTP 402 gate. Drop into FastAPI or Flask; + verifies X-PAYMENT signatures and emits the standard + accepts[] envelope. The whole pay-per-call story in one + middleware. +
    +
    + docs + · + PR #19 + · + source +
    -
    -

    Reference code — current step

    -
    Click a step on the left to see the wire-level snippet.
    + +
    +
    +

    zap_transport

    + in PR +
    +
    + Binary wire for PaymentOffer / PaymentProof + over luxfi/zap. Zero-allocation, + roughly an order of magnitude smaller than JSON. First production + consumer of zap_py. +
    +
    + docs + · + PR #21 +
    +
    + +
    +
    +

    gas_tracker · gas_budget

    + shipped +
    +
    + Hard gas budgets — per-hour, per-day — so a runaway agent loop can't + drain its own treasury. Closes the #1 footgun of autonomous on-chain + agents. +
    +
    + docs + · + PR #14 +
    +
    + +
    +
    +

    nonce_manager

    + shipped +
    +
    + Client-side nonce manager with reorg protection. The piece every + shipping agent eventually has to write — written once, here. +
    +
    + docs + · + PR #11 +
    +
    + +
    +
    +

    AgentEscrow.sol

    + shipped +
    +
    + Trustless escrow with timeout, challenge period, and mutual cancel. + Solidity contract + Python client + CLI. The native-ETH variant is + drafted as an EIP. +
    +
    + docs + · + PR #8 + · + EIP draft +
    +
    + +
    +
    +

    pq · post-quantum

    + north star +
    +
    + liboqs wrapper for PQ signatures (Dilithium / Falcon / + SPHINCS+). Every PaymentProof carries a + signature_alg + signature; the wire format is PQ-ready out + of the box. PQ-0 → PQ-5. +
    +
    + docs + · + spec +
    +
    + +
    +
    +

    a2a_x402 adapter

    + shipped +
    +
    + Adapter between Google's A2A (Agent-to-Agent) framework and x402. + Lets an A2A agent be paid in the open x402 protocol. +
    +
    + docs + · + PR #29 +
    +
    + +
    +
    +

    multi-chain settlement

    + design v0.1 +
    +
    + The chain-agnostic settlement surface. Notary attestation for v1, + ZK-relay for v2, native PQ verification on LUX. Spec landed in + docs/multi-chain-settlement.md. +
    +
    + how it fits + · + spec + · + PR #71 +
    +
    + +
    +
    +

    mpc_wallet

    + shipped +
    +
    + Multi-party-computation wallet — threshold signatures across an + agent fleet, no single key on any one machine. +
    +
    + docs + · + PR #53 +
    +
    + +
    +
    +

    mpp/session

    + shipped +
    +
    + Multi-party payment sessions — open a streaming channel under a + budget cap, settle on close. The Tempo / Stripe-style rail for + long-running agent work. +
    +
    + docs + · + PR #53 +
    +
    + +
    +
    +

    adapters/lucidly

    + shipped +
    +
    + syUSD auto-park for idle agent balances. Any USDC the agent isn't + actively using earns yield by default; pulled back automatically + when needed for a payment. +
    +
    + docs + · + PR #53 +
    +
    + +
    +
    +

    OracleAggregator

    + shipped +
    +
    + Oracle-mediated escrow release — releaseByAttestation + lets a designated oracle aggregate sign off on delivery, settling + the escrow without on-chain dispute. +
    +
    + docs + · + PR #52 +
    +
    -
    +
    -

    Compatibility matrix

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    x402MPPAP2Circle Nanoswitchboard escrow
    TransportHTTP header on 402HTTP + Tempo txsA2A over gRPC/JSON-RPCHTTP/SDK, off-chain+onchainHTTP + chain txs (escrow)
    Settlement assetUSDC (multichain)USDC on Tempo, fiat via SPTprotocol-agnosticUSDC nanopaymentsnative ETH/token + USDC
    Agent ↔ Agentindirect (server intermediary)nativenativevia Circle Walletsnative
    Agent ↔ API / MCP serverprimary use casesupportedvia payments facilitatornativevia wrapper
    Streaming / sessionsper-request (v2 adds multi-step)streamed micro-txs per sessionyes (verifiable intent mandate)nanopayments < $0.000001timeout + challenge-period escrow
    Dispute / refundnone (idempotent retry)SPT + card dispute railsAP2 verifiable intent → issuerCircle policy + ruleson-chain timeout + refund
    Fiat railscrypto onlyvia Stripe SPTcard networks (Visa, MC)via Circle on/off rampcrypto only
    LicenseApache-2.0Apache-2.0Apache-2.0proprietary SDK + open skillsMIT
    -
    + +
    +
    +

    multi-chain · LUX-settled

    + #59 resolved · design v0.1 +
    +

    + Switchboard is chain-agnostic and token-agnostic: agents transact on + whichever chain fits the job (TRON for sub-cent micropayments, AVAX C-chain + for liquidity, Base for USDC, ETH for canonical native-ETH escrow), with + whichever asset both sides agree on. LUX is the preferred settlement layer — + PQ-signed receipts anchor on LUX regardless of where the underlying transfer + happened. +

    -

    How switchboard fits

    -
    -

    The open rails above settle agent payments; they don't manage the agent side — keys, nonces, gas budgets, counterparty escrow. switchboard fills that gap:

    -
      -
    • Agent wallets — MPC key management for autonomous actors (tracked in #1).
    • -
    • Client-side nonce manager with reorg protection — so a bursty agent doesn't brick its own queue.
    • -
    • Gas budget tracker — rolling hour/day limits, auto-pause on exhaustion (#14, merged).
    • -
    • Agent-to-agent escrowAgentEscrow.sol with timeout + challenge-period refund (#2, merged).
    • -
    • x402 / MPP / AP2 server middleware — so switchboard-managed agents can respond to 402 Payment Required and initiate MPP sessions out of the box (tokenomics / integration issues incoming).
    • -
    -
    +
    +
    +

    execution chains

    +
    TRON TRC-20 · sub-cent fee
    +
    Avalanche C EVM · USDC.e
    +
    Base EVM · USDC native
    +
    Ethereum L1 native-ETH escrow
    +
    +
    +
    +

    settlement

    +
    LUX C-chain PQ receipt anchor
    +
    SettlementRegistry hash + envelope
    +
    ZAP wire format canonical receipt
    +
    Dispute evidence on-chain on LUX
    +
    +
    -
    +

    + Design v0.1 landed (PR #71, + closing #59). + The chosen path is a notary attestation model for v1, upgradable in-place to + ZK-relay as Groth16 verification matures on LUX. TRON finality at 19 blocks, + Avalanche C-Chain at 5, LUX at 2. Full spec, finality tables, and per-chain + considerations in + + docs/multi-chain-settlement.md. +

    + - + +
    +
    +

    rails compatibility

    + x402 · MPP · AP2 · Circle · escrow +
    +

    + The four open agent-payment rails of 2026, plus on-chain escrow. Switchboard + speaks all of them — the same module surface, the same wire envelope, the + same agent identity. The matrix shows where each rail draws the line. +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    capabilityx402MPPAP2Circle NanoAgentEscrow
    HTTP 402 paywall✓ nativevia sessionvia card
    streaming micropaymentsper-call✓ nativecard auth✓ native
    trustless escrow✓ native
    refund / disputeoff-chainoff-chain✓ chargebackoff-chain✓ on-chain
    chain-agnosticn/a (card)USDC only✓ (with #59)
    PQ-signed✓ via switchboard✓ via switchboard✓ via switchboard
    binary wire (ZAP)n/an/a
    +
    +
    + + +
    +
    +

    what's novel

    + we think nobody else is doing these +
    +

    + Open questions and proposals switchboard is pushing into the world of agent + payments. Each is filed as a research issue in the public tracker. PRs + and counter-proposals welcome. +

    + +
    - + +
    +
    +

    composable refund policies

    + innovation +
    +
    + Refund logic as on-chain plugins. Compose pro-rata, gated, time-decay, + slashing — every contract gets the policy it needs without forking the + escrow. +
    +
    + #46 +
    +
    + +
    +
    +

    adversarial conformance harness

    + shipped +
    +
    + A test corpus every other-language implementation of the wire format + must reject. The negative space defines the protocol as much + as the positive space. Vectors in + tests/conformance/adversarial_vectors.json. +
    +
    + #45 + · + PR #62 +
    +
    + +
    +
    +

    private x402

    + innovation +
    +
    + Pay an agent without revealing the amount. Range proofs on the + payment envelope; the server learns "yes, paid above threshold," nothing + more. +
    +
    + #44 +
    +
    + +
    +
    +

    receipt aggregation

    + innovation +
    +
    + N off-chain micropayments collapse into 1 on-chain settlement. Save + gas on the boring stretch; settle on-chain when the relationship ends + or stakes cross a threshold. +
    +
    + #43 +
    +
    + +
    +
    +

    .well-known/agent-payment.json

    + shipped +
    +
    + Discoverable agent identity hub at a well-known URL. Pay-to address, + accepted assets, PQ key, ZAP endpoint, rate-limit policy — one + fetch, one source of truth. Schema in + docs/well-known-agent-payment.md. +
    +
    + #42 + · + PR #61 + · + schema +
    +
    + +
    +
    + + +
    +
    +

    post-quantum, by default

    + PQ-0 → PQ-5 · in flight +
    +

    + Every PaymentOffer and PaymentProof carries an + explicit signature_alg and a signature in that algorithm. + Dilithium is the default; Falcon and SPHINCS+ are first-class. The wire + format is forward-compatible — when NIST adds a Round-4 winner, the + registry adds an entry; the protocol doesn't change. +

    + +
    # two-line PQ signing on a payment offer
    +from switchboard import PaymentOffer
    +from switchboard.pq import sign, ALG_DILITHIUM3
    +
    +offer = PaymentOffer(
    +    pay_to="0xYourTreasury...",
    +    asset="0x036Cb...e7e",
    +    network="base-sepolia",
    +    amount="1000",           # 0.001 USDC
    +    signature_alg=ALG_DILITHIUM3,
    +)
    +offer.signature = sign(offer.canonical(), pq_key)
    + +

    + On the verifier side, dispatch on signature_alg happens at + the adapter layer. On LUX, the spec assumes native PQ precompiles and + ZK precompiles for Groth16 verification (per + + docs/multi-chain-settlement.md) — confirming this + against current luxfi/* code is the next open question. +

    +
    + + +
    +
    +

    the lab · 16 scenes

    + single-file canvas, no build +
    +

    + Animated scenes that play out every protocol switchboard documents. Each + scene is ~150 lines and follows the SCENES.md + contract. Touch the scene for a tooltip, scrub the simulator slider, or + step through with space / n / r. +

    + +
    +
    01
    x402 paywall
    +
    02
    escrow + refund
    +
    03
    streaming MPP
    +
    04
    AI compute auction
    +
    05
    human-in-the-loop
    +
    06
    treasury rebalance
    +
    07
    signed oracle pulls
    +
    08
    PQ envelope
    +
    09
    taxi handover
    +
    10
    café walk-by
    +
    11
    food delivery
    +
    12
    split bill
    +
    13
    native-ETH escrow
    +
    14
    subscription
    +
    15
    multi-city trip
    +
    16
    + add yours
    +
    + +

    + Open the full lab → +

    +
    + + +
    +
    +

    30-second quickstart

    + one route, one middleware +
    +

    + Gate any HTTP route behind on-chain payment. The middleware does the rest — + verifies the X-PAYMENT envelope, emits the accepts[] response, + lets the caller settle in any supported asset on any supported chain. +

    + +
    from fastapi import FastAPI
    +from switchboard.x402_middleware import X402Middleware
    +
    +app = FastAPI()
    +app.add_middleware(
    +    X402Middleware,
    +    pay_to="0xYourTreasury...",
    +    asset="0x036CbD53842c5426634e7929541eC2318f3dCF7e",  # USDC on Base Sepolia
    +    network="base-sepolia",
    +    price="1000",           # 0.001 USDC per call
    +    paths=["/agent-only"],
    +)
    +
    +@app.get("/agent-only")
    +def agent_only():
    +    return {"ok": True, "payload": "this cost the caller 0.001 USDC"}
    + +

    + Full backend reference at docs · install via + pip install switchboard[pq]. +

    +
    + + + + +