Skip to content

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

@up2itnow0822

Description

@up2itnow0822

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions