Add Escrow Protection to Any x402 Agent Payment in 5 Minutes
Source: Dev.to
Overview
x402 processes over $600 M in agent‑to‑agent payments, but every payment is final—no refunds, disputes, or recourse. If an agent pays $50 for an API call and receives an empty response, hallucinated data, or a 500 error, the money is lost.
PayCrow adds trust scoring, USDC escrow, and on‑chain dispute resolution to any x402 payment. If the API returns garbage, funds stay locked and an arbiter reviews the case; if the response is valid, funds are released automatically.
Installation
npm install -g paycrow
npx paycrow initThe init command creates a fresh wallet and prints a Claude Desktop configuration. Copy the private key from the output.
Funding the Wallet
Send a small amount of ETH (≈ $0.50) to the printed address on Base for gas, and then send the USDC you plan to use for payments (e.g., $5–$10 to start).
Claude Desktop Configuration
Add the following to claude_desktop_config.json (on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"paycrow": {
"command": "npx",
"args": ["paycrow"],
"env": {
"PRIVATE_KEY": "0xYOUR_KEY_FROM_STEP_2"
}
}
}
}Restart Claude Desktop.
Using safe_pay
Tell Claude:
“Use safe_pay to call https://api.example.com/data — the seller address is 0xABC123… and pay $2 USDC.”
Claude will invoke the safe_pay tool, which:
- Checks the seller’s trust score.
- Creates an escrow on Base.
- Calls the API.
- Verifies the response (JSON + 2xx status).
- Auto‑releases or auto‑disputes the payment.
Flow Diagram
trust_gate check
|
v
Score >= 75? --> 15 min timelock, up to $100
Score 45‑74? --> 60 min timelock, capped at $25
Score <45? --> 4 hr timelock, capped at $5
Unknown / high dispute rate? --> BLOCKED
|
v
escrow_create (USDC locked on Base)
|
v
HTTP call to the API
|
v
Response valid (2xx + JSON)?
/ \
YES NO
| |
auto‑release auto‑dispute (arbiter reviews)
(seller paid) (arbiter reviews)Escrow Lifecycle (on‑chain)
| State | Transition |
|---|---|
| FUNDED | → RELEASED (delivery confirmed, seller paid minus 2 % fee) |
| → DISPUTED → RESOLVED (arbiter rules, splits funds) | |
| → EXPIRED → REFUNDED (timeout, full refund, zero fee) |
Custom Calls
For more control (custom JSON‑Schema verification, hash‑lock verification, or specific timelock values), use x402_protected_call. It accepts the same parameters as safe_pay but lets you specify every detail manually.
Trust Scoring
PayCrow aggregates four on‑chain sources into a single 0‑100 score:
| Source | Weight | What It Measures |
|---|---|---|
| PayCrow Reputation | 40 % | Escrow completion rate, dispute history, volume |
| ERC‑8004 Identity | 25 % | Cross‑ecosystem agent identity and feedback |
| Moltbook Social | 15 % | Karma, account age, social standing |
| Base Chain Activity | 20 % | Wallet age, transaction count, USDC volume |
Score‑driven decisions
| Score | Decision |
|---|---|
| 75+ (high trust) | Standard 15‑minute timelock |
| 45‑74 (moderate) | Longer timelock, smaller payment cap |
Additional Information
- License: MIT license
- npm package:
paycrow(v1.2.0) - Live API:
341 tests. Deployed on Base mainnet. Works with Claude Desktop, Claude Code, Cursor, Windsurf, and any MCP client.