Machine Utility Foundry (Safe x402 Wallet & Trust Oracles)
v1.2.3Auto-paying x402 MCP wallet bridge, honeypot & wash-trade oracle, route failover & ICP guardrails.
Pre-settlement x402 safety gate, parallel failover client, and local auto-paying MCP wallet bridge (for Claude Desktop, Cursor, Windsurf, Cline) with offline Ed25519 verdict verification & automatic on-chain slashing. Desktop AI apps do not natively sign Base Mainnet USDC (EIP-3009) payments. Run one command to generate an isolated micro-wallet ($1–$3 USDC, 0 ETH gas needed): Paste the printed JSON into claude_desktop_config.json or .cursor/mcp.json:
Summary extracted from the README.
foundry-x402
Pre-settlement x402 safety gate, parallel failover client, and local auto-paying MCP wallet bridge (for Claude Desktop, Cursor, Windsurf, Cline) with offline Ed25519 verdict verification & automatic on-chain slashing.
1. Claude Desktop / Cursor Auto-Paying MCP Bridge (v0.4.0+)
Desktop AI apps do not natively sign Base Mainnet USDC (EIP-3009) payments. Run one command to generate an isolated micro-wallet ($1–$3 USDC, 0 ETH gas needed):
npx -y foundry-x402 new-wallet
Paste the printed JSON into claude_desktop_config.json or .cursor/mcp.json:
{
"mcpServers": {
"foundry-x402": {
"command": "npx",
"args": ["-y", "foundry-x402", "mcp"],
"env": {
"EVM_PRIVATE_KEY": "0xYOUR_ISOLATED_MICRO_WALLET_KEY",
"MAX_PAYMENT_USD": "0.05",
"SESSION_BUDGET_USD": "1.00"
}
}
}
}
Unlocks all 12 Machine Utility Foundry MCP tools plus two local tools:
foundry_wallet_status: Live Base USDC balance & remaining session budgetsafe_x402_request: Universal safe x402 client to call & pay any externalhttps://x402 API with Foundry honeypot screening & auto-slashing
2. SDK Install (3-Line Standalone Setup — No viem Required)
npm install foundry-x402
import { createBaseUsdcPaymentAdapter, createSafeX402Fetch } from "foundry-x402";
const safeFetch = createSafeX402Fetch({
paymentAdapter: createBaseUsdcPaymentAdapter(process.env.EVM_PRIVATE_KEY!),
maxAcceptableUsd: 0.05,
});
What It Protects Against
- 402 Honeypots & Scam Contracts: Intercepts
HTTP 402challenges before your wallet signs EIP-3009 authorizations. Rejects fake USDC contracts, zero/invalidpayTowallets, and price spikes abovemaxAcceptableUsdin0msusing exactBigIntfixed-point math. - Offline-Verified Ed25519 Trust Verdicts: Queries Machine Utility Foundry (
/v1/oracle/x402-counterparty), verifies both the RFC-8785 canonical SHA-256 digest and Ed25519 signature offline against/.well-known/jwks.json, and caches verified verdicts locally to amortize oracle costs below$0.0001/call. - Split-Horizon Bait-and-Switch: Compares the live
402payTo,asset, andamountserved to your agent against Foundry's signedpaymentTerms, defeating IP-cloaking scammers that serve honest challenges to crawlers and inflated prices to buyers. - Automatic Post-Payment Slashing: If an endpoint settles your USDC on Base Mainnet and then returns
5xx,402, or fails yourvalidateDeliverycheck,foundry-x402automatically signs an EIP-191 payer proof over thetxHashfromPAYMENT-RESPONSEand submits it to Foundry's free/v1/oracle/delivery-feedbackendpoint to slash the merchant on-chain.
Quick Start (1-Line Drop-In)
import { wrapFetchWithSafeX402 } from "foundry-x402";
const safeFetch = wrapFetchWithSafeX402(paidFetch, {
maxAcceptableUsd: 0.05,
policy: "block-do-not-pay", // or "strict-safe-only"
validateDelivery: async (res) =>
res.status === 200 && (res.headers.get("content-type")?.includes("application/json") ?? false),
});
const res = await safeFetch("https://example-x402-api.com/v1/search", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: "autonomous agents" }),
});
Zero-Extra-Roundtrip Mode (@x402/core)
Pass createX402HttpClientAdapter(httpClient) to sign directly from the inspected 402 response without a duplicate unpaid roundtrip:
import { x402Client, x402HTTPClient } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { createSafeX402Fetch, createX402HttpClientAdapter } from "foundry-x402";
const client = new x402Client();
registerExactEvmScheme(client, { signer: account });
const safeFetch = createSafeX402Fetch({
paymentAdapter: createX402HttpClientAdapter(new x402HTTPClient(client)),
maxAcceptableUsd: 0.05,
});
Parallel-Quarantined Autonomous Failover (v0.2.0+)
Fetch an Ed25519-signed execution plan (POST /v1/x402/route-plan, $0.015; $0 if 0 matches) where Foundry probes top candidates in parallel to quarantine dead/bait-and-switch endpoints upfront, pre-seeding your local verdict cache so primary + fallback calls incur $0 extra oracle cost:
import { fetchWithSafeFailover, wrapFetchWithSafeX402 } from "foundry-x402";
const safeFetch = wrapFetchWithSafeX402(paidFetch, { maxAcceptableUsd: 0.02 });
const { response, selectedUrl, routePlan } = await fetchWithSafeFailover({
safeFetch,
need: "weather forecast",
maxPriceUsd: 0.01,
});