Metadata-Version: 2.5
Name: x402-payee-guard
Version: 0.1.1
Summary: Screen the payee before your x402 agent pays: blocks sanctioned, drainer and stablecoin-frozen addresses with one line on x402Client.
Project-URL: Homepage, https://veriql.app
Project-URL: Documentation, https://veriql.app/openapi.json
Project-URL: x402scan listing, https://www.x402scan.com/server/b43a466b-e90b-41bf-a7a8-1502cde22f10
Author: Veriql
License-Expression: MIT
License-File: LICENSE
Keywords: agent-payments,ai-agents,compliance,ofac,payee-screening,sanctions,stablecoin,usdc,usdt,x402
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Security
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: x402>=2.20
Provides-Extra: httpx
Requires-Dist: x402[httpx]>=2.20; extra == 'httpx'
Provides-Extra: requests
Requires-Dist: x402[requests]>=2.20; extra == 'requests'
Description-Content-Type: text/markdown

# x402-payee-guard

Screen the payee before your x402 agent pays.

An x402 client pays whatever `payTo` address a 402 response names. An agent
that finds sellers on its own will, sooner or later, be handed an address it
has never seen. This package adds one hook to the official
[x402 Python SDK](https://pypi.org/project/x402/): before the client signs a
payment, it looks up the `payTo` address and aborts the payment when the
address is

- on the US Treasury OFAC SDN sanctions list,
- a known drainer, phishing or scam address, or
- frozen by a stablecoin issuer (Tether or Circle; EVM and Tron addresses).
  Issuers freeze addresses tied to hacks, scams and sanctions. USDT sent to a
  Tether-frozen address cannot be moved out again; Circle's contract rejects
  USDC sent to a blacklisted one.

EVM, Bitcoin, Solana and Tron addresses are accepted.

```python
from x402 import x402ClientSync
from x402_payee_guard import guard_payees

client = x402ClientSync()
# client.register("eip155:*", ExactEvmScheme(signer=...))   # your usual setup
guard_payees(client)
```

That's it. Every payment the client creates afterwards is screened first. A
`do_not_pay` payee makes the client raise `x402.PaymentAbortedError` instead of
signing.

## Cost and who runs the lookup — please read

The lookup is [Veriql](https://veriql.app)'s `/api/v1/payee` endpoint, and
**each uncached lookup costs USD 0.01**, paid over x402 in USDC on Base from the
same wallet your client already pays with. This package is made by Veriql,
which runs that endpoint.

- Answers are cached per address: `no_known_risk` for 1 hour, `do_not_pay` for
  24 hours (both configurable), so an agent that pays the same seller all day
  pays for one lookup an hour.
- The guard's own USD 0.01 payment to Veriql is not screened again.
- Pass `trusted=[...]` for sellers you already know; they are never looked up.
- Prefer another provider or your own list? Pass `fetcher=` and nothing is
  sent to Veriql (see below).

## Install

```bash
pip install "x402-payee-guard[requests]"   # for x402ClientSync
pip install "x402-payee-guard[httpx]"      # for the async x402Client
```

Python 3.10+. The only dependency is `x402` (2.20 or newer).

## Async client

```python
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402_payee_guard import guard_payees

client = x402Client()
# client.register("eip155:*", ExactEvmScheme(signer=...))
guard_payees(client)

async with x402HttpxClient(client) as http:
    r = await http.get("https://seller.example/paid-endpoint")
```

## Options

```python
guard = guard_payees(
    client,
    allow_ttl=3600,          # seconds a no_known_risk answer is reused
    block_ttl=86400,         # seconds a do_not_pay answer is reused
    trusted=["0x..."],       # never looked up
    on_incomplete="allow",   # or "block" when not every check could answer
    on_error="allow",        # or "block" when the lookup itself fails
    on_decision=lambda verdict, allowed: print(verdict.verdict, allowed),
    timeout=20.0,
)
```

| Option | Default | Meaning |
|---|---|---|
| `allow_ttl` | `3600` | Cache lifetime of a `no_known_risk` answer, in seconds. `0` disables. |
| `block_ttl` | `86400` | Cache lifetime of a `do_not_pay` answer. |
| `trusted` | `()` | Addresses never looked up. EVM addresses match case-insensitively. |
| `on_incomplete` | `"allow"` | What to do when some checks could not answer. |
| `on_error` | `"allow"` | What to do when the lookup fails (network, unpaid, bad response). Errors are never cached. |
| `on_decision` | `None` | Callback `(Verdict, allowed: bool)` for your logs or metrics. |
| `fetcher` | `None` | Replace the HTTP lookup: `address -> Verdict` (an `async` function for the async client). |
| `endpoint` | Veriql `/api/v1/payee` | Lookup URL, if you run a compatible service. |
| `timeout` | `20.0` | HTTP timeout for the lookup, in seconds. |

The defaults fail open: a network blip never stops your agent from paying. For
a treasury agent, `on_incomplete="block", on_error="block"` fails closed.

## Verdicts

| Verdict | Meaning | Guard |
|---|---|---|
| `do_not_pay` | At least one check found the address (sanctioned, listed, or frozen). | blocks |
| `no_known_risk` | Every applicable check answered and none found it. | allows |
| `incomplete` | Some checks could not answer. | `on_incomplete` |
| `error` | The lookup itself failed. | `on_error` |

`no_known_risk` means none of these lists has the address today. It is not a
promise about the seller.

You can also call the guard directly, for example before an ordinary transfer:

```python
v = guard.check("0x...")       # or: await guard.acheck("0x...")
if v.blocked:
    print(v.reasons)
```

## Your own lookup

```python
from x402_payee_guard import Verdict, guard_payees

DENY = {"0x...", "0x..."}

def my_lookup(address: str) -> Verdict:
    return Verdict(address, "do_not_pay" if address.lower() in DENY else "no_known_risk")

guard_payees(client, fetcher=my_lookup)
```

## Links

- API description: [veriql.app/openapi.json](https://veriql.app/openapi.json)
- x402scan listing: [x402scan.com/server/b43a466b-e90b-41bf-a7a8-1502cde22f10](https://www.x402scan.com/server/b43a466b-e90b-41bf-a7a8-1502cde22f10)
- Free browser check for one address: [veriql.app](https://veriql.app)
- Read the freeze lists yourself, no API: [`stablecoin-freeze-check`](https://pypi.org/project/stablecoin-freeze-check/)

## License

MIT
