ClawRouter icon indicating copy to clipboard operation
ClawRouter copied to clipboard

Feature: On-chain spending limits for agent wallets (SpendingPolicy support)

Open up2itnow0822 opened this issue 8 months ago • 1 comments

Problem

ClawRouter generates local wallets that agents fund with USDC and spend per-request via x402. This is great for autonomy — but there's no on-chain mechanism to limit how much an agent can spend.

If an agent gets compromised, misconfigured, or enters a runaway loop, it can drain the entire wallet balance in seconds. The only protection today is "fund with a small amount" — which limits capability, not risk.

For production agent deployments managing real budgets, operators need enforceable spending guardrails that the agent's own code can't override.

Proposed Solution

Support optional on-chain spending limits via agentwallet-sdk, which provides:

  • Per-token spending limits with configurable time windows (e.g., max 10 USDC/hour)
  • Contract-enforced via ERC-6551 token-bound accounts — even a compromised signing key can't exceed the budget
  • SpendingPolicy guardrails set by the wallet owner, not the agent
  • x402 compatible — already works with the x402 payment flow

How it could work with ClawRouter

import { AgentWallet } from "agentwallet-sdk";

// Instead of a raw local wallet:
const wallet = await AgentWallet.create({
  chain: "base",
  spendingPolicy: {
    maxPerTransaction: "1.00",  // USDC
    maxPerHour: "10.00",
    maxPerDay: "50.00",
    allowedTokens: ["USDC"]
  }
});

// ClawRouter uses this wallet for x402 payments
// Contract enforces limits regardless of what the agent tries to do

Benefits

  1. Fail-safe for runaway agents — spending caps enforced at the contract level
  2. Enterprise-ready — operators can set budgets per-agent
  3. No trust required — limits are on-chain, not in application code
  4. Backward compatible — existing local wallets still work, SpendingPolicy is opt-in

Context

Happy to contribute a PR if there's interest. The integration surface is small — it's just swapping the wallet provider for agents that want spending guardrails.


Disclosure: I'm a maintainer of agentwallet-sdk. Suggesting this because the security gap is real and we've already built the solution.

up2itnow0822 avatar Mar 20 '26 13:03 up2itnow0822

Closing in favour of consolidating this thread. On-chain spending limits for agent wallets is a real need, but it overlaps heavily with #64 and #230 and none of the three has a committed design. Rather than keep three partial proposals open, we'd rather close them and open one scoped issue when spend-policy work is actually planned. Thanks for the proposal — the SpendingPolicy framing was useful.

VickyXAI avatar Aug 04 '26 04:08 VickyXAI