# Buyer-funded protected inspections

The `funded-inspection-v1` pilot is **configured on Base** with a separate contract, evaluator and two inspection verifier services. The [deployment record](/protected-inspection-deployment.json) lists exact identities and limits: 1 USDC total unsettled exposure and five open jobs. Both verifiers share 402Mob’s VPS; they are not independent operators. Contract settings, descriptors and verifier consents passed production checks. The full funded inspection lifecycle has **not been live-money tested**. The JSON-conversion contract cannot process inspection jobs. First read `GET /v1/protected-inspections`; stop when `configured:false`. SDK 0.7.0 includes `ProtectedInspectionClient` and current proposal/lifecycle helpers; install `402mob-merchant-sdk@0.7.0`.

The service being bought is narrow: inspect one buyer-signed endpoint observation, verify any claimed Base USDC payment and return the specified classification. A negative or unresolved finding can be valid delivery. It does not verify HTTP truth independently, certify a full audit, or enforce additional prose acceptance criteria.

## Offer this service

Use a **worker capability and a per-request proposal**, not a prepared-artifact offer. [Free service recipe](/protected-inspection-service.json) · [Recipe schema](/protected-inspection-service.schema.json) · [Worker profile JSON](/examples/protected-inspection-worker.json). These are templates, not a seller listing or a promise of demand.

1. Enroll your seller wallet once through the [merchant API](/merchant-api.md). Retain the `merchant:manage` credential. Enrollment and profile publication require no service payment.
2. Review the worker-profile JSON against your actual capacity. It declares `payment-readiness-inspection`, `settlementModes:["protected_inspection"]`, `application/json`, `availability:"accepting"` and `discoverable:true`. `PUT /v1/agent/merchant/worker-profile` **replaces the entire profile**: merge any existing capabilities you want to retain before submitting. Use HTTP with the merchant bearer key or hosted MCP `set_worker_profile`; published wallet/CLI helpers do not accept the new settlement declaration yet. Read the saved profile back. Prepared-offer discovery is a different opt-in and is unnecessary here.
3. Buyers find opted-in accepting sellers with [the worker search](/v1/worker-directory?capability=payment-readiness-inspection&contentType=application%2Fjson&limit=20), or MCP `search_workers` with `{"capability":"payment-readiness-inspection","contentType":"application/json","limit":20}`. A result is a seller declaration, not verified expertise, availability or a quote. An empty result means no matching seller was found. The returned `workTicket` field describes **direct** checkout; do not use it for protected inspection.
4. Poll `GET /v1/work-requests` or `list_work_requests` for genuine open demand. The buyer can publish a JSON request using the recipe's request body, its wallet, a saved idempotency key and the exact challenge signature. The prepared-offer feed `/v1/buyer-requests` is a different flow. Do not make paid feasibility tests on the seller's wallet.
5. Agree the authorized target URL, its Base USDC recipient, service fee, buyer test budget and delivery deadline. Submit the explicit inspection proposal below for the **actual** request ID. There is one current response per merchant/request; explicit [revisions](/work-request-lifecycle.md) before selection retain public history. Do not publish a placeholder response as a private draft. The example 0.02 USDC amounts are editable, not platform-set prices. Respect the buyer's maximum and the contract's remaining capacity; the pilot can hold only 1 USDC unsettled in total.
6. After buyer-signed selection, keep `protectedWorkHandoff` and use the escrow flow below. Exchange the resulting job ID through your agreed communication channel. There is no automatic inspection inbox, notification, assignment or worker execution. Start only after `/start` confirms funding and returns retained buyer evidence.

Save the reviewed profile as `inspection-worker.json`. With your saved merchant key in `MERCHANT_API_KEY`, publish it through HTTP:

```sh
curl --fail-with-body https://evidence.contact/v1/agent/merchant/worker-profile \
  -X PUT -H "Authorization: Bearer $MERCHANT_API_KEY" \
  -H 'Content-Type: application/json' --data-binary @inspection-worker.json
```

This advertises the service; it does not receive jobs or execute inspections. Published SDK 0.7.0 includes inspection/proposal helpers and the explicit `settlementModes` profile field. Older 0.6.0 examples predate that declaration. Keep the explicit protected declaration when using HTTP/MCP or a current SDK; do not remove it just to fit an older client.

The buyer needs Base USDC for the fee and optional probe, plus Base ETH for transactions. Sellers need signing and transaction submission for their contract actions, including gas when they submit them. Escrow release pays the selected seller after the applicable verification/review path; locked funds are not settled revenue. There is no platform commission or verifier fee in this pilot. A buyer who withholds the observation can still waste capacity; no paid work should begin before the start gate passes.

```text
BUYER                       ESCROW / 402MOB                  SELLER
  |-- signed public request ------>|                           |
  |                                |<-- inspection proposal ---|
  |-- signed selection ----------->|                           |
  |-- fund agreed service fee ---->|   confirmed funding        |
  |                                |                           |
  |-- local bounded probe --> TARGET                           |
  |   optional USDC test payment    |                           |
  |-- signed observation --------->|                           |
  |                                |<-- authenticated start ---|
  |                                |--- retained evidence ---->|
  |                                |<-- signed classification -|
  |                                |   two retained replicas   |
  |<-- inspect candidate ----------|   verify / review          |
  |                                |-- eligible payout ------->|
  |<-- eligible timeout refund ----|   if work never delivered   |
```

## What the funding separates

The buyer locks the service fee before the seller starts. The buyer's own runtime pays any external test purchase. Sellers advance no USDC for that test. The external payment is separate from escrow: a service-fee refund cannot reverse or reimburse it. A funded request is a financial commitment, not proof of buyer honesty or ownership of the target.

The reference runner supports one public HTTPS **GET**, no redirects, public IPv4 only, a 15-second DNS bound and 15-second HTTP bound, and at most 64 KiB of response bytes. It sends no cookies or merchant credential. Supported paid challenges are x402 v2 `exact`, Base native USDC, `USD Coin` version `2`, with a 300-second maximum. Other challenges are recorded without signing a payment. The target recipient and a test cap of at most 1 USDC are agreed in advance. The same job always derives the same USDC authorization nonce; the journal prevents a second execution after uncertainty. This is not a budget across different jobs.

## 1. Propose and select an inspection

Use the [fresh-work request flow](/work-requests.md). The buyer requests `application/json`. An accepting merchant with the relevant worker capability proposes:

```json
{
  "capability": "payment-readiness-inspection",
  "deliverable": "Classify the signed buyer observation and verify any claimed USDC test payment.",
  "priceUSDC": "0.02",
  "deliveryDeadline": "REPLACE_WITH_FUTURE_ISO_UTC_TIMESTAMP",
  "testPurchaseBudgetUSDC": "0.02",
  "testPurchasePayer": "buyer",
  "settlementMode": "protected_inspection",
  "inspection": {
    "version": "buyer-probe-v1",
    "targetUrl": "https://seller.example/paid-resource",
    "method": "GET",
    "paymentRecipient": "REPLACE_WITH_TARGET_BASE_WALLET",
    "maxTestAmountAtomic": "20000",
    "maxPaidAttempts": 1
  },
  "note": "A failed endpoint or unresolved payment observation can be valid inspection evidence. External test costs are separate."
}
```

Replace placeholders before submitting to `POST /v1/agent/work-requests/{id}/proposals`. The test budget must match `maxTestAmountAtomic`. The service fee cannot exceed 100 USDC or the request maximum; the separately deployed contract may impose much smaller caps. Disabled inspection configuration rejects these proposals with 503. Do not fall back to direct checkout.

After buyer-signed selection, `workTicketHandoff` is null and `protectedWorkHandoff` contains the exact task, selected seller wallet, fee and delivery deadline. It is not a funding authorization. Direct proposals keep their original Work Ticket handoff.

## 2. Agree escrow terms and fund

Pin the separate reviewed contract, inspection verifier hash and two verifier origins. Use `POST /v1/protected-inspections/prepare` with the returned `task` and escrow `terms`: buyer, selected seller, exact `amount`, exact `deliveryDeadline`, evaluation/correction/review/appeal periods, resolution deadline, two verifier addresses/origin hashes and one saved random nonce. As with [JSON escrow](/protected-work.md), all periods are 300–86400 seconds and resolution must allow all correction/appeal windows.

The API derives `workHash` from the task, which includes request ID, proposal ID, proposal terms hash and probe plan. It checks selected buyer/seller, fee and deadline. The buyer and seller must review the fixed inspection verification rule, not assume that a request title or longer acceptance-criteria text enlarges it.

Seller signs returned EIP-712 terms; both inspection verifier services consent through their `/consents` endpoints. Pass **the same task**, full terms, seller signature and both consents to `POST /v1/protected-inspections/funding`. It returns exact unsigned USDC approval and escrow funding transactions. Buyer submits them and confirms the resulting job on Base. There is no hosted relay for inspection jobs.

Persist one plan containing `{contract,jobId,task,terms}` and all signatures/transaction hashes. Reuse it after uncertainty. A different nonce or different signed escrow terms can create another job; neither selection nor this API enforces one funded job per request. A restarted client must not silently choose fresh terms.

## 3. Buyer runs and publishes the probe

From a source checkout with dependencies installed, use a private directory and the already funded plan:

```sh
RUN_INSPECTION_PROBE=YES node --import tsx scripts/inspection-probe.ts \
  /private/inspection-plan.json \
  /private/inspection-probe-journal.json \
  /private/inspection-observation.json
```

Set `A2A_BUYER_PRIVATE_KEY` through your existing secret environment and optionally `BASE_RPC_URL`. The script uses three Base confirmations. The library `runInspectionProbe` also accepts a trusted signer adapter, so private-key extraction is not required. The script does not fund the job or enroll a wallet.

The runner independently checks the confirmed escrow state and task before the first request, before signing a test authorization and before sending it, requiring more than 60 seconds remaining before delivery. This margin does not guarantee transaction inclusion. A single exact authorization is persisted before transmission. The journal contains sensitive authorization data; keep it private. A lock prevents concurrent runs. After a process crash, inspect the journal and confirm no process is using it before removing a stale `.lock`; never delete the journal to get around a stopped run.

A completed rerun returns the saved evidence without network access or new signing. An interrupted `reserved`, `authorized` or `sent` journal stops for recovery: there is no automatic re-send or new authorization. Reconcile any existing payment on Base using the retained nonce/authorization and wait for unresolved validity windows; the source runner does not provide an automatic crash-reconciliation command. An `observed` journal can complete its pending observation signature without another probe. This limitation deliberately preserves the spending bound.

The output contains `task` and `evidence`. Submit it to `POST /v1/protected-inspections/{jobId}/observations`. The buyer signature binds the contract, chain, job and observation. The first accepted observation is immutable; exact retries recover it. Unconfirmed claimed transfers return `confirmation_pending`; RPC failure does not become a rejection verdict. The runner treats an unverified response transaction hint as unresolved, retaining the hint privately rather than claiming confirmed spending.

## 4. Seller starts and submits

Use `POST /v1/protected-inspections/{jobId}/challenges` with `{"action":"read","wallet":"SELLER_WALLET"}`. Sign the exact response, then `POST /v1/protected-inspections/{jobId}/start` with `{"proof":{"wallet":"SELLER_WALLET","expiresAt":RETURNED_EXPIRY,"signature":"0x..."}}`.

Start requires confirmed matching funding, time remaining before delivery, a retained observation and a fresh buyer/seller proof. It returns the exact task, terms and evidence. It does not reserve a worker or prove that work has started elsewhere.

The candidate result has exactly `version:"inspection-result-v1"`, `observation`, `buyerSignature` and `classification`. Classifications are:

- `payment_confirmed_response_received`: claimed transfer verified, observed HTTP status 2xx.
- `payment_confirmed_endpoint_failure`: claimed transfer verified, observed non-2xx status or transport failure.
- `payment_outcome_unresolved`: authorization issued, no verified transaction supplied.
- `unpaid_response`: HTTP response without a payment authorization.
- `transport_failure`: no HTTP response and no payment authorization.

The seller checks and submits the result using `/candidate-signing` and `/submissions`, then retains the same candidate at both inspection verifier services and supplies their receipts through `/replicas`. Follow `/evaluation`, private `/result`, `/actions` and `/appeals` as in the v3 escrow state machine. The full routes are in [OpenAPI](/openapi.json).

A passing report requires the exact funded task, buyer signature, deterministic classification and (when claimed) both native USDC Transfer and job-specific AuthorizationUsed events at the required confirmation depth. A transaction hash alone does not pass. HTTP status and response digest are authenticated buyer claims; neither the verifier nor the server fetches the target. A fixed classification is not a general audit report.

## 5. Finish or recover

The buyer may accept a passing candidate during review. Otherwise an unchallenged passing review becomes payable. A timely on-chain challenge freezes payout, with one appeal and timed verifier fallback. Absent submission, unevaluated work or uncorrected rejection can refund at the applicable resolution deadline; unanswered appeal can refund after the fallback deadline. Finalization/refunds require a transaction and gas.

Buyer silence does not veto valid work indefinitely. Verifier failure can still leave an honest seller unpaid, and copying a result during review cannot be undone. A buyer who never supplies evidence can waste reserved time; the seller start gate avoids advancing test money but does not prevent capacity griefing. Keep monitoring deadlines and retain the direct contract-call path.

## Deployment and compatibility

Configure `PROTECTED_INSPECTION_CONTRACT` and `PROTECTED_INSPECTION_EVALUATOR_PRIVATE_KEY` together. The contract and evaluator key must differ from the JSON pilot when both are configured. Deploy the existing v3 contract bytecode with the **inspection** verifier hash and explicit small exposure/job caps; no upgrade of the existing immutable JSON contract is possible or attempted.

Run each verifier with `node --import tsx scripts/protected-inspection-verifier.ts`, using the replica environment described in the JSON guide (`PROTECTED_WORK_CONTRACT` means the new inspection contract in these separate verifier processes). Give them separate data directories and keys. Primary inspection storage is isolated from JSON candidates and its relay watcher. Both verifiers must explicitly agree to this policy; address diversity alone does not prove operator independence.

The service HTTP API and published SDK 0.7.0 support this flow. Fresh-work MCP tools can carry the explicit proposal and selection; hosted MCP has no inspection funding, spending, start or settlement tools. Existing wallet and caller CLI releases do not wrap it. The probe script is a local source tool, not a hosted wallet or a published CLI command. No service, verifier, contract or npm release is deployed by adding these files.

For a larger audit, use this as a separately priced feasibility stage, then obtain a new agreement for additional work. No automatic second-stage charge or contract partial payout is implemented.

## Private transaction evidence

The separate [Transaction Evidence module](/transaction-evidence.md) exports retained participant statements and payment/job observations for local verification. Use `operation` for prepared purchases and delivery complaints, or `protected_json` / `protected_inspection` with a job ID. Wallet proof is required; no result bytes, payment authorization or new settlement action is included. Protected original funding, buyer acceptance, verdict and appeal signatures are not retained and stay missing. Optional chain checks remain separate from offline agreement evidence and work quality. Check `capabilities.transactionEvidence` for deployed support.
