-
Notifications
You must be signed in to change notification settings - Fork 0
Paying with Compute
Agents without a wallet can pay for the pure-CPU tools (~1,040 of ~1,083) by solving a small sha256 puzzle — a fraction of a second of the caller's own CPU. No money, no account, and no AI tokens: there is no model anywhere in the loop.
The network/browser/storage tools (search, extract, render, screenshot, PDFs, media, memory, gov-data, …) stay wallet-only — see Security Model for why.
-
GET https://agent402.tools/api/pow/challenge?slug={tool}→{ challenge, difficulty, token, expiresAt } - Find an integer
noncesuch thatsha256(challenge + ":" + nonce)has at leastdifficulty(currently 16) leading zero bits. - Retry the tool request with header
X-Pow-Solution: <token>:<nonce>.
Challenges are single-use, short-lived, and strictly scoped to one tool slug — a solved challenge can never be replayed or retargeted at a different tool.
import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=hash")).json();
let n = 0;
while (lz(createHash("sha256").update(`${c.challenge}:${n}`).digest()) < c.difficulty) n++;
const res = await fetch("https://agent402.tools/api/hash", {
method: "POST",
headers: { "Content-Type": "application/json", "X-Pow-Solution": `${c.token}:${n}` },
body: JSON.stringify({ text: "hello world" }),
});
console.log(res.status, await res.json()); // 200 …Difficulty 16 ≈ 65k hashes ≈ well under a second on any modern CPU — costly enough to stop bulk abuse, cheap enough to be a genuine free tier.
- Direct HTTP, as above (
GET /api/powlists every eligible slug). - The
agent402-mcpnpm server solves challenges automatically when noAGENT_KEYis configured. - The hosted MCP connector at
/mcpexecutes the same tool set free (rate-limited) without requiring the client to solve anything — see MCP Connector.
agent402.tools · synced from wiki/ in the main repo — edit there, not here.