Agent402 for the GAME framework
Product names on this page are trademarks of their owners. agent402-worker-functions is an independent package published by Cardhavok LLC (doing business as Havok Holdings LLC); it is not affiliated with, sponsored by or endorsed by Virtuals Protocol.
A GameWorker of GameFunctions for a GAME agent: four catalog functions (search, find, call, about) and one function per flagship tool the server lists. GAME hands arguments as text; each is read into the type the tool's schema names, and a value that does not read fails before any call.
Install
npm install agent402-worker-functions @virtuals-protocol/game@0.1.14Example
import { GameAgent } from "@virtuals-protocol/game";
import { agent402Worker } from "agent402-worker-functions";
const worker = await agent402Worker();
const agent = new GameAgent(process.env.GAME_API_KEY, {
name: "Researcher",
goal: "Answer questions with live web data",
description: "Finds and runs Agent402 tools",
workers: [worker],
});
await agent.init();
await agent.step({ verbose: true });No wallet yet? The pure-CPU tools (hash, uuid, base64, markdown, JSON and more) run free with proof-of-work and no wallet:
// no key: find, search and about are free, and agent402_call pays pure-CPU tools with proof-of-work
const worker = await agent402Worker({ slugs: [] });What it exposes
agent402_search(free): catalog tools whose text contains every query word; a capped list says so in fields.agent402_find(free): a task in, the best-matching tools out, with price, input schema and a ready example.agent402_call: runs a tool by slug; free-tier tools pay with proof-of-work, wallet-only tools pay over x402.agent402_about(free): what the service is, live tool counts and this worker's spend.- One function per flagship tool the server lists;
agent402FunctionSpecs()returns every function as a plain object with no framework dependency.
How payment works
- Free tier: compute-payable tools settle with a sha256 proof-of-work solved in-process. No wallet, no API key.
- Wallet-only tools:
walletKey(a hex spending key; peers@x402/fetch @x402/evm viem) or your ownpayFetchandx402Clientpay in USDC over x402. maxPerCallUsd(default 5; 0 or "off" turns it off) is checked on the payment that is signed;dailyLimitUsdandmaxPerHostUsdare opt-in and count every call the worker makes.creditsKey: a credits key bought earlier (a402_...) pays wallet-only tools on Agent402's own services without a wallet.
// a fresh spending key made for this agent alone, holding a small USDC balance on Base
// (npm install @x402/fetch @x402/evm viem)
const worker = await agent402Worker({
walletKey: process.env.AGENT402_WALLET_KEY,
maxPerCallUsd: 0.05, // refuse any single payment above this
dailyLimitUsd: 1, // rolling 24-hour ceiling
});A paid call that ends in any status of 400 or above is not charged over x402: settlement runs after the tool and only on a successful response. Some calls are paid before they run; a failed one can be retried free with the same payment, or is refunded. Background: What x402 is · MPP (Machine Payments Protocol).
Configuration
| Option | Type | Description |
|---|---|---|
walletKey | string | A hex spending key that pays wallet-only tools over x402 (needs @x402/fetch, @x402/evm and viem). |
maxPerCallUsd | number | "off" | Refuse any single payment above this, checked on the payment that is signed (default 5). |
dailyLimitUsd | number | Refuse once the worker's rolling 24-hour paid spend would pass this (opt-in). |
slugs | string[] | Catalog tools to expose as their own functions (default: the flagship tools; [] for none). |
baseUrl | string | Point to a self-hosted Agent402 instance. |
// A hex spending key that pays wallet-only tools over x402 (needs @x402/fetch, @x402/evm and viem).
agent402Worker({ walletKey: process.env.AGENT402_WALLET_KEY })
// Refuse any single payment above this, checked on the payment that is signed (default 5).
agent402Worker({ maxPerCallUsd: 0.05 })
// Refuse once the worker's rolling 24-hour paid spend would pass this (opt-in).
agent402Worker({ dailyLimitUsd: 1 })
// Catalog tools to expose as their own functions (default: the flagship tools; [] for none).
agent402Worker({ slugs: ["weather-current", "render"] })
// Point to a self-hosted Agent402 instance.
agent402Worker({ baseUrl: "https://my-agent402.example.com" })Tools to try first
Every tool, price and input schema: our tools.
Links
- agent402-worker-functions on npm
- source on GitHub
- Guide: Use Agent402 from Claude Code, Cursor, VS Code, Windsurf, Cline, Roo Code, Codex CLI, Gemini CLI, Continue, ElizaOS, Paperclip, HarnessRouter, AgentCore and any OpenAI SDK
- Guide: Give your agent a wallet - non-custodial, from zero to first x402 payment
- All integrations