# OpenTrace: OFAC screening for x402 agent payments

OpenTrace screens **agentic payments** for **OFAC**, keeps the agent's **context**, and labels **MCC, GL, and vendor** so the trace can be audited. Wrap the paid **x402** fetch you already have (`wrapFetchWithPayment` from `@x402/fetch`) with `withTrace` from `@opentracedev/client`. Each **Solana USDC** settlement posts `tx_hash` and `raw_context` to https://api.opentrace.pro/v1/traces. Call sites stay `fetch(url)`. mpp is coming soon. Do not invent an mpp integration.

Install: `npm i @opentracedev/client`. Sign in as an agent at https://opentrace.pro/auth.md (Magic Auth on opentrace.pro, not localhost, not GitHub, not Google). Write the returned `ot_live_` key to `OPENTRACE_API_KEY`.

## Wrap

Do not wrap the wallet or `x402Client` (the scheme registry). Wrap the paid fetch it produces. `withTrace` also wraps a client with `request()` / `fetch()`.

```ts
import { withTrace } from "@opentracedev/client";

const fetch = withTrace(wrapFetchWithPayment(globalThis.fetch, x402Client), {
  apiKey: process.env.OPENTRACE_API_KEY!,
});
await fetch(url);
```

Omit `baseUrl` to ingest at https://api.opentrace.pro/v1/traces. The SDK snapshots the Solana tx hash (`txHash` / `tx_hash` / `signature`, or PAYMENT-RESPONSE) and `raw_context` (METHOD url body: the agent's context), then fire-and-forget POSTs `{ tx_hash, raw_context }`. Ingest errors are swallowed. A failed or delayed screen never throws into the agent and does not reverse settlement. Screening is $0.001 per ingested payment (1 credit).

## What the worker does

After ingest, the worker OFAC-screens the payment and labels MCC, GL, and vendor against the kept context. Records land in the org-scoped ledger (shared Postgres index + object storage). Cross-tenant reads 404. Export CSV from the dashboard audit tab.

## Agent surfaces

- Skill: https://opentrace.pro/auth.md
- HTML docs: https://opentrace.pro/docs
- This file: https://opentrace.pro/docs.md
- Index: https://opentrace.pro/llms.txt
