Spend Permission Simulator
Model the capped, recurring allowance a smart wallet grants to an AI agent or a subscription biller: set the token, the per-period allowance and the validity window, replay spend attempts to see which ones the contract accepts or reverts, and get the EIP-712 hash the account signs.
Follows Coinbase SpendPermissionManagercoinbase/spend-permissions, main branch·verified Nov 2026— period arithmetic, revert order and EIP-712 hash follow the contract source; hashes checked against eth-account 0.14.0; nothing is read from a chain
10 USDC a day for 30 days — an agent paying for APIs and data
USDC on Base.
Token decimals:
One spend() call per line: time (ISO 8601 in UTC, or unix seconds) then the amount in USDC. Lines are replayed in block-time order.
| Time (UTC) | Amount | Result | Period | Spent in period | Left |
|---|---|---|---|---|---|
| 2026-11-12T09:00:00Z | 4.00 | ✓ transferred | 2026-11-12T00:00:00Z → 2026-11-13T00:00:00Z | 4.00 | 6.00 |
| 2026-11-12T13:30:00Z | 5.50 | ✓ transferred | 2026-11-12T00:00:00Z → 2026-11-13T00:00:00Z | 9.50 | 0.50 |
| 2026-11-12T18:00:00Z | 1.00 | ✗ reverts ExceededSpendPermission(10500000, 10000000) | 2026-11-12T00:00:00Z → 2026-11-13T00:00:00Z | 9.50 | 0.50 |
| 2026-11-12T18:05:00Z | 0.50 | ✓ transferred | 2026-11-12T00:00:00Z → 2026-11-13T00:00:00Z | 10.00 | 0.00 |
| 2026-11-13T00:00:00Z | 10.00 | ✓ transferred | 2026-11-13T00:00:00Z → 2026-11-14T00:00:00Z | 10.00 | 0.00 |
| 2026-11-16T08:00:00Z | 12.00 | ✗ reverts ExceededSpendPermission(12000000, 10000000) | 2026-11-16T00:00:00Z → 2026-11-17T00:00:00Z | 0.00 | 10.00 |
| 2026-12-12T00:00:00Z | 1.00 | ✗ reverts AfterSpendPermissionEnd(1797033600, 1797033600) | — | — | — |
- Permission hash
- 0xcae79edc5a5516473dd2adee18ad31bfe38cce3e85fb4e7fe856f7505dda9298
- Struct hash
- 0x3414b50855d9b847c2f1ee193ae45add7234a77ce9bbbdad389f6edb1edb77ad
- Domain separator
- 0x3187a50f7c68cc46a370ce9830bcd5da649e5f41d60dd75ba256ced435601516
- Domain
- Spend Permission Manager · version 1 · chainId 8453 · 0xf85210B21cC50302F477BA56686d2019dC9b67Ad
The permission hash is what getHash() returns, what the account signs for approveWithSignature(), and the key the contract stores approval, revocation and period spend under. Any change — one unit of allowance, a different salt, another chain — is a different permission.
- Read the lifetime total, not the per-period figure. Exposure is allowance × periods; a small daily cap with a far-off end is a large grant.
- Unused allowance does not roll over, and periods are fixed windows from start, not a sliding 24 hours: a spender can take a full allowance just before a boundary and another just after.
- Only the spender can call spend() and the tokens go to the spender. The permission says nothing about where they go next — recipient allowlists are the spender's job (or a wallet policy engine's).
- Revocation is the kill switch. The account (or the spender) can revoke at any time; a revoked hash can never be re-approved, so issue a new salt.
- One token per permission. A budget across USDC and EURC is two permissions (or a batch signed once).
- The cap is on-chain, the judgement is not. The contract stops overspending; it cannot tell a prompt-injected purchase from a wanted one. Keep per-call limits and anomaly checks in the agent runtime too.
How spend permissions work
A spend permission lets a smart account hand a third party — an app, a subscription biller, an AI agent's key — the right to pull a token up to a fixed allowance in each period, between a start and an end time. It is the on-chain counterpart of a card-on-file mandate with a limit: the payer signs once, the payee collects without asking again, and the contract enforces the cap. Unlike an ERC-20 approve, it resets on a schedule, expires by itself and can be revoked without touching the token.
This page follows Coinbase's open-source SpendPermissionManager, a singleton that a Coinbase Smart Wallet adds as an owner. The account approves a permission with a transaction or an EIP-712 signature; the spender then calls spend(permission, value) and the manager moves the tokens from the account to the spender, reverting if the call is outside the validity window or would take the period's running total over the allowance. The simulator replays that arithmetic in the browser; it does not read any chain, so it cannot know whether a permission was really approved, revoked or already partly used.
Where this fits in agentic payments
An agent that pays for APIs with x402 needs a balance it can spend without a human signing every request, and its owner needs a hard ceiling on the damage a compromised or confused agent can do. Spend permissions, session keys and wallet policy engines are the three common ways to set that ceiling; the Agent Wallets guide compares them and shows how they line up with card-side controls such as agent-bound network tokens and AP2 mandates.
Questions
Is the period a rolling window?
No. Periods are fixed intervals counted from start: [start + n × period, start + (n + 1) × period). The running total resets at each boundary, and the last period is cut off at end.
How is this different from an EIP-3009 authorization?
An EIP-3009 transferWithAuthorization is a single signed transfer of an exact amount to a named recipient, usable once. A spend permission is a standing budget: many pulls, any amounts, up to the cap in each period.
Does it work with any wallet?
The contract modelled here works with Coinbase Smart Wallet accounts that have added the manager as an owner. Other smart-account stacks offer the same idea under different names (session keys, ERC-7715 permission grants); the limits to review — amount, period, expiry, token, spender — are the same.