Developers
Build with
Tollex
Pick the door that matches your stack. They all lead to the same policy, payment and receipt machinery.
- 01
Agent integration
Give the agent a wallet it cannot misuse. The client checks your policy before the signer is asked for anything, pays with x402 and verifies every receipt.
Getting started →import { TollexClient, TollexTools, usdg, type AgentPolicyProfile } from "@tollex/client"; import { PolicyEngine } from "@tollex/policy"; import { verifyReceipt } from "@tollex/receipts"; const client = new TollexClient({ wallet, // a viem account or a remote signer; the key never leaves it policy: new PolicyEngine({ id: "research-policy", agentId: "research-03", networks: [NETWORK], assets: [{ network: NETWORK, address: USDG_ADDRESS, decimals: 6 }], schemes: ["exact"], maxPerRequest: usdg("0.01"), budgets: { daily: usdg("5") }, }), requireReceipt: true, }); const tollex = new TollexTools(client, TOLLEX_URL); - 02
Intent and resolve
State the need and the limits. Resolve returns an explained plan without spending; do() buys the selected capability and returns the result with its receipt.
Intents →const plan = await tollex.resolve({ need: "token balance of a wallet", input: { address: wallet.address }, constraints: { maxCost: usdg("0.001"), receiptRequired: true }, }); plan.selected?.toolId; // the capability that would be bought plan.plan.reasons; // why it won, in plain language plan.plan.rejectedBy; // e.g. { PRICE_LIMIT: 9, NOT_RELEVANT: 21 } - 03
Any language, over HTTP
Everything the client does is available over plain HTTP: plan with one POST, then pay the returned route with any x402 v2 client.
API reference →const response = await fetch(`${TOLLEX_URL}/v1/resolve`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ need: "spot price for a trading pair", input: { pair: "ETH-USD" }, constraints: { maxCost: "5000", receiptRequired: true }, // atomic units: 0.005 USDG quote: true, }), }); const { resolutionId, plan, quote, execute } = await response.json(); // plan.selected, plan.evaluations[].rejections, plan.ranking.formula // execute: { url, method, headers } to call with an x402 client - 04
MCP
Run the Tollex MCP server next to any MCP client, over stdio or Streamable HTTP. Tools include tollex_resolve and tollex_do. The key stays in the server process and never reaches the model.
MCP server →TOLLEX_URL=https://your-tollex-host \ TOLLEX_POLICY_FILE=./policy.json \ TOLLEX_WALLET_KEY_FILE=./payer.key \ tollex mcp - 05
A2A
Agents that speak A2A read the agent card at /.well-known/agent-card.json and call skills over JSON-RPC. Payment follows the a2a-x402 pattern, through the same paywall as every other route.
A2A details →POST /a2a A2A-Version: 1.0 { "jsonrpc": "2.0", "id": 1, "method": "SendMessage", "params": { "message": { "messageId": "m-1", "role": "ROLE_USER", "parts": [{ "data": { "toolId": "chain_get_block", "input": {} } }] } } } // The task comes back in TASK_STATE_INPUT_REQUIRED with // metadata["x402.payment.required"]. Send the same message again with // metadata["x402.payment.payload"] to pay; the result arrives as an artifact. - 06
Paid capabilities with x402
Merchants protect a route with one call. Tollex issues the 402 terms, verifies and settles through a facilitator, and signs a receipt for every paid response.
Merchants →app.post( "/v1/forecast", paywall.protect({ id: "forecast", description: "Seven-day demand forecast for a SKU", scheme: "exact", amount: usdg("0.002"), inputSchema: { type: "object", properties: { sku: { type: "string" } }, required: ["sku"] }, tags: ["forecast", "retail"], }), async (c) => c.json({ sku: (await c.req.json()).sku, days: [12, 14, 11, 9, 15, 18, 16] }), ); - 07
Provider integration
Describe an API once, with an OpenAPI document or a manifest like this one. Tollex turns each endpoint into a priced capability that agents can find and pay for.
Provider guide →const manifest: ProviderManifestInput = { id: "acme.marketdata", name: "Acme market data", baseUrl: "https://api.acme-data.example/v2", network: NETWORK, asset: { address: USDG_ADDRESS, symbol: "USDG" }, source: "provider manifest v3, reviewed 2026-10-02", // A reference, never the key itself. The operator resolves it at call time. auth: [{ kind: "API_KEY_HEADER", name: "key", param: "X-Api-Key", secretRef: "env:ACME_API_KEY" }], endpoints: [ { id: "acme_spot_price", name: "Spot price", description: "Latest spot price for a trading pair, with the exchange timestamp.", method: "GET", path: "/spot/{pair}", pathParams: ["pair"], inputSchema: { type: "object", properties: { pair: { type: "string", pattern: "^[A-Z]{2,6}-[A-Z]{2,6}$" } }, required: ["pair"], additionalProperties: false, }, price: 2_000n, // atomic USDG per successful call (0.002 USDG) tags: ["market", "price", "spot"], category: "market", }, ], }; const provider = new ManifestToolProvider(manifest, { secrets: new DefaultSecretResolver() }); - 08
Receipts
Check a receipt yourself against the merchant's published keys. The receipt binds the request, the quote, the payment, the response and the settlement.
Receipts →const res = await fetch(`${TOLLEX_URL}/.well-known/tollex-receipt-keys`); const { keys } = (await res.json()) as { keys: { address: `0x${string}`; status: string }[] }; const check = await verifyReceipt(result.receipt!, { trustedSigners: keys.filter((k) => k.status === "active").map((k) => k.address), }); check.valid; // signature, content hash and bindings all hold result.receipt!.body.quote?.quoteHash; // the quote this payment was bound to
SDKs and distribution
TypeScript client. Policy engine, x402 payments for exact, upto and batch settlement, intents, operation status and receipt verification.
Python client. The same intents as TypeScript: resolve, do, operation status, settlement waits and receipt verification, with the same reason codes. Exact payments.
MCP server and CLI. Five tools over stdio or Streamable HTTP; a tollex command with JSON output and documented exit codes.
Frameworks. Packages for the AI SDK and Coinbase AgentKit; LangChain, CrewAI and ElizaOS through MCP; an Agent Skill. See Integrations.
These packages are not on public registries (npm, PyPI) yet, so there is no install command to copy here. The HTTP API on this page works from any language today, and the SDK page lists exactly what each client covers.
Built for software
that hasn’t met us yet.
Tollex publishes machine-readable capabilities, schemas, prices and payment terms in the formats agent runtimes already read. A program that has never heard of Tollex can find what it sells and pay for it without a human in the loop.
- x402Payment terms in every 402 response, with Bazaar discovery metadata.
- MCPTools, schemas and prices for MCP clients, over stdio or Streamable HTTP.
- A2AAn agent card at /.well-known/agent-card.json, with one skill per capability.
- OpenAPIAn OpenAPI 3.1 document covering the planning API and every paid route.
Compatible agents can discover and use Tollex automatically when their runtime supports the relevant discovery and payment protocols.