Your AgentKit agent pays for resources through AgentKit’s x402 actions, and you want a limit in
dollars, per payment and per day, on what it can sign. AgentKit’s x402 actions build their own
x402 client on every call. budget.guardAgentKit() puts the budget on every client the provider
builds, so each payment is checked against the wallet’s budget before it is signed, whatever
terms the merchant sends.
$ npm install walletcap @coinbase/agentkit
$ npx walletcap set --wallet 0xYourAgentWallet --per-payment 0.02 --per-day 1
import { X402ActionProvider } from '@coinbase/agentkit';
import { openBudget } from 'walletcap';
const budget = openBudget({ wallet: '0xYourAgentWallet' }); // the budget `walletcap set` created
const x402 = budget.guardAgentKit(new X402ActionProvider());
// AgentKit.from({ walletProvider, actionProviders: [x402] })
createX402Client. The test suite type-checks this recipe with tsc.The AgentKit row is opt-in because AgentKit installs about 1.3 GB:
$ npx -p walletcap-crash-test -p @coinbase/agentkit@0.10.4 walletcap-crash-test --agentkit
The agent approves the merchant’s 1¢ offer on Base Sepolia; the merchant lists $1.00 on Base mainnet, to another address, first.
| Control | Result |
|---|---|
| AgentKit 0.10.4 | signed $1.00 on Base mainnet to the first-listed address, valid 4 days; reported $0.01 on Base Sepolia |
| walletcap, 2¢ a payment | signed $0.01 on Base Sepolia, the offer the agent approved |
walletcap limits how much AgentKit pays, not which offer it pays. It passes over the $1.00, which the merchant asks to be valid 4 days: it signs only terms valid an hour or less, and at most 2¢. The offer left is the 1¢ one the agent approved. A merchant that listed the approved offer valid two hours, and a 2¢ one valid five minutes, would get the 2¢ one.
CI runs this row on every pull request and checks it. For 0.3.0 the check prints:
AgentKit 0.10.4: signed $1.00 on Base mainnet, reported $0.01 on Base Sepolia; walletcap signed the $0.01 on Base Sepolia.