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.

Stage 2 drift checks can spend from a StallRow recheck pack (config recheck_pack_id): $0.004 per uncached check, no per-check settlement, and the guard warns at 25 and 10 credits remaining (balance reads are free). Without a pack, drift checks pay $0.005 per uncached check as before.

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.1

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.1
File Size Uploaded Provenance Actions
x402_guard-0.1.1.tar.gz 27.8 kB With provenance Details for x402_guard-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 53.9 kB

Release files / x402_guard-0.1.1.tar.gz

Download URL x402_guard-0.1.1.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
55291756a595fddef46b157ab5d364831bb5e00cb5cddd35d5d9a869d40c5615
BLAKE2b-256 checksum
How to use checksums
361f82d3b92a4c89dcf0bda92e440858915ef36aeae2c0a93ec73e30f47afbb0
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 26, 2026.

Transparency log

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

Download URL x402_guard-0.1.1-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebad40b47c64985dfe4ee3057aaeee51be49805d325788a7b1e63052e4f16379
BLAKE2b-256 checksum
How to use checksums
5b32ad22fcad8a950c84c523afd38a083cfb5fa0ca6c7c509437d70ce3b6eead
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 26, 2026.

Transparency log

Security for x402-guard 0.1.1

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.1.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 26, 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