Skip to main content

x402-guard (Python)

The payment-path seatbelt for x402 buyer agents. Install GuardedClient once inside your paying code; from then on, every x402 payment you make is pre-flighted through Verdict Row before anything is signed:

  1. Settled pre-flight (free) — settled.tools' scout has actually bought from most endpoints worth paying. The guard asks what its test purchases found. Hard veto only on a failed delivery or a not-payable verdict; a verified delivery corroborates; nothing_to_compare is noted, never a veto; Settled being down or silent is a pass-through, never a block.
  2. Drift check (StallRow Recheck, $0.005, cached) — if the endpoint is new to you, or your last look is older than the TTL (default 24h), the guard pays Recheck to fingerprint the endpoint's live payment terms and diffs them against its local store. payTo or asset changed → hard block. Price moved more than the configured % (default 20%) → block. Schema / description / other changes → warn. Inside the TTL the cached result is used and this stage costs zero.
  3. RouteVerdict gate (optional, $0.05, cached) — a first-ever payment at or above a threshold (default $0.10) requires a TRUSTED verdict ≥ your trust floor (default 80).
  4. Your spend caps — per-payment, per-endpoint-daily, and global-daily caps from your own config, checked against the guard's local ledger before signing. The guard refuses first; it never signs and discovers later.

Every decision — allow, warn, block, with the reason chain and what the checks cost — is appended to a local audit log (JSONL) you can read. Blocks raise GuardBlocked carrying the full decision.

from eth_account import Account
from x402_guard import GuardConfig, GuardedClient

account = Account.from_key("0x...")  # your key, your env — never logged
guard = GuardedClient(account=account, config=GuardConfig(
    global_daily_cap_units=1_000_000,  # $1.00/day across everything
))

result = guard.pay("https://some-service.example/v1/thing", {"input": 1})
print(result.outcome.response)          # the service's real answer
print(result.decision.summary())        # what was consulted, what it cost

No signer (account=None) = dry-run: the pipeline runs what it can for free, paid stages are noted as skipped, would-be blocks land on result.decision.blocked, and nothing is ever paid.

What it costs you

Stage Cost When
Settled pre-flight free every payment
Recheck drift check $0.005 first look per endpoint per TTL (24h default)
RouteVerdict gate $0.05 first big payment (≥ $0.10 default) per TTL
The guard itself $0 it's a library

What it cannot do

It judges pre-payment signals only: the inspector's delivery record, the endpoint's current terms vs. its own history, a trust verdict, and your caps. It cannot judge the paid payload — whether the answer you bought was good is your application's problem. It also cannot help if an endpoint's terms change between the drift check and your payment inside the same TTL window; shorten the TTL if that window matters to you.

Configuration

GuardConfig in code, or environment variables via GuardConfig.from_env() (X402_GUARD_*: stage toggles, URLs, TTL, price-change %, failure policies — "warn" or "block" when a check service itself errors — USD caps, store/audit paths). Local state lives in ~/.x402-guard/ (sqlite cache + spend ledger, JSONL audit log) — your machine, your data, never transmitted.

An external budget object (anything with authorize(units) / record(units, label=) — e.g. verdict-loop's DailySpendCap) can be passed as budget=; every settled payment the guard makes, checks included, is authorized and recorded against it, so an embedding app keeps exactly one cap.

Part of Verdict Row: Token Verdict · RouteVerdict · ListSmith · StallRow · listsmith-ci (the seller-side shovel)

Metadata

Release files for x402-guard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for x402-guard 0.1.0
File Size Uploaded Provenance Actions
x402_guard-0.1.0.tar.gz 25.5 kB With provenance Details for x402_guard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for x402-guard 0.1.0
File Interpreter ABI Platform Actions
x402_guard-0.1.0-py3-none-any.whl Python 3 none any Details for x402_guard-0.1.0-py3-none-any.whl

Total release size: 50.1 kB

Release files / x402_guard-0.1.0.tar.gz

Download URL x402_guard-0.1.0.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
73bf291359938b7554c42bc53e34ab84c675954593be0ad46382546ad9488354
BLAKE2b-256 checksum
How to use checksums
2a75d6f24a21540f5651300618937cc7b3f9f2d83d3481e8b6e61b4d11a6e7ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / x402_guard-0.1.0-py3-none-any.whl

Download URL x402_guard-0.1.0-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3d2bc5de45f26f0530a960b909fc196ee902d8c8c9390d99fe2cbd9c06bda69
BLAKE2b-256 checksum
How to use checksums
65047ea75eebc9dec7eb72dfde80c5dde769883643c1b326bbe2ae98b639c599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for x402-guard 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for x402_guard-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page