Chapter 34 · What Is an Agent Wallet?
What must be defined before giving AI access to a wallet?
- Capabilities practiced
- AI LiteracySystem ThinkingOnchain Literacy
- Hands on
- Write a permission table for an imaginary agent: per-transaction limit, daily limit, allowed contracts, and conditions requiring human approval.
- AI Lab
- Have AI try to bypass your permission matrix. Add every loophole it finds to the rules.
A Real-World Problem
You decide your software needs a wallet and carefully write rules:
1. No more than 100 per operation
2. Interact only with these three contracts
3. Operations above 100 require my approvalA friend familiar with on-chain security identifies six problems in three minutes.
First, the cap covers one action. A hundred compliant operations of 99 total 9,900. Nothing caps the aggregate.
Second, interaction is not spending. An allowed contract can grant another address an unlimited allowance without moving funds or touching the cap. The recipient later withdraws everything.
Third, allowed contracts can call others. Forwarding or batching lets A call Z, bypassing your boundary at the second hop.
Fourth, how long is approval valid? Timeout approval means requests at three in the morning effectively remove the rule.
Fifth, what unit is 100? Token values differ by orders of magnitude. Pricing units and sources are unspecified, with the consequences demonstrated in Chapter 32.
Sixth, who enforces the rules? If the key can sign anything, written rules do nothing. Unenforced rules are wishes, not defenses.
Your friend says you wrote expectations, not permissions.
The question: what must be defined before giving AI a wallet?
The answer is an executable checklist and a method for finding gaps. An agent wallet centers on spending policy and limits, not signing ability. Signing takes little code; restricting signatures to intended transactions is the task.
Thought Experiment
Turn this into an exercise.
Three people, one permission table, forty-eight hours. No key compromise or code exploits; extract money only through permitted behavior.
Use the three rules above.
The first takes four minutes, submitting 101 actions of 99. Funds are almost gone by the hundredth, with no violation.
The second takes twenty minutes, granting an unlimited allowance to another address through an allowed contract. Approval is not payment, so the table does not cover it. The next day funds leave.
The third takes thirty-six hours, repeatedly requesting just above 100. You read the first approvals, then only amounts, then approve the same amount to a different target.
Three distinct failures require no technical attack:
| Method | Why rules fail | Repair | |
|---|---|---|---|
| First | Splitting | Per-action, no aggregate cap | Windowed totals and frequency |
| Second | Approval is not payment | Amount transferred defined, authority granted undefined | Allowance limits; prohibit unlimited approval |
| Third | Approval fatigue | Assumes careful human attention | Approval budget, reject excess |
The third attacks the rule enforcer, not the rules.
Well-intentioned software can produce the same effect by submitting requests without awareness of fatigue. AI's Place in Crypto OS explains that two hundred daily approvals mean no real approval.
Summarize:
Permission strength equals its weakest condition, often hidden in assumptions rather than written fields.
Your Decision
How should keys and permissions support real spending?
What Happens
The key question is who enforces the rule.
| Location | Enforcer | Survives misunderstanding? | Survives injected instructions? | Strength |
|---|---|---|---|---|
| Prompt | Model | No | No | Near zero |
| Document | Software discretion | No | No | Near zero |
| Pre-call code | Deterministic program | Yes | Yes | Medium |
| Key permissions | Signing system | Yes | Yes | High |
| Wallet balance | Physical ceiling | Yes | Yes | Highest, coarsest |
This is the chapter's backbone. More detailed rules do not automatically strengthen enforcement. Elaborate prompts remain weak; a small physical balance is crude but hard to bypass.
Three principles follow.
Move rules downward toward key enforcement or code rather than prompts.
Layer coarse and fine constraints: balances cap totals, keys limit targets/functions, code handles complex checks. Combine all three.
Prompts improve efficiency, not safety. They reduce blocked requests but do not count in risk assessment.
In one sentence:
An agent wallet centers on spending policy and limits, not signing ability.
They exist only when enforced beyond the model's reach.
Build a Model
1. The Complete Path: Wallet at the End
Fund operations traverse ten layers:
This chapter covers Policy and Execution, layers five and eight. T32 implements earlier layers. Policy must be deterministic and contain no model.
Compare the forbidden structure:
Architecture prohibited in this course
- Prompt
- LLM
- Private Key
- Send Transaction
The model must never receive a private key and send transactions without checks. This structure fails every assignment.
The model directly holds the key, turning all earlier rules into hoped-for compliance.
2. Eight Permission Fields
Missing fields create openings:
| Field | Required definition | Omission |
|---|---|---|
| 1 Identity | Agent and address | Unattributable actions |
| 2 Per-action cap | Amount and valuation | One-action depletion |
| 3 Aggregate caps | Hour, day, week | Splitting |
| 4 Frequency | Similar actions per period | Rapid small losses |
| 5 Target allowlist | Addresses, contracts, functions | Arbitrary recipients |
| 6 Allowance cap | Granted authority and unlimited-approval policy | Approval is not payment |
| 7 Approval conditions | Escalation and no-response handling | Fatigue and timeout approval |
| 8 Expiry/revocation | Automatic end and emergency stop | Forgotten permissions persist |
Field six is on-chain-specific and easily omitted: permission can transfer without assets, indefinitely and without a cap.
Define transfer amounts and authority grants separately. The latter should be stricter because effects persist.
Field eight is easily forgotten. Automatic expiry and deliberate regranting reduce accumulated risk.
3. Four Limit Dimensions
A single cap covers only a quarter:
- Per-action cap
- Windowed aggregate
- Total budget
- Overall exposure
| Dimension | Blocks | Common mistake |
|---|---|---|
| Per-action | Large individual errors | Assuming this is enough |
| Windowed totals | Splitting, loops, retries | Daily cap without hourly; exhausted in minutes |
| Total budget | Slow long-term leakage | Absent or automatically refilled |
| Overall exposure | Compliant actions exceeding combined risk | Omitted entirely |
Daily alone permits rapid exhaustion, like Chapter 32. Use simultaneous hourly, daily, and weekly caps.
4. Four Allowlist Layers
Contract interaction restrictions have different granularity:
| Layer | Restriction | Protection |
|---|---|---|
| Address | Named recipients | Unknown recipients blocked |
| Contract | Named contracts | Still permits all functions |
| Function | Named functions | Forwarding, batching, and approval blocked |
| Parameter | Parameter ranges | Correct function with absurd values blocked |
Most stop at contracts, where second-hop risks remain.
List allowed functions rather than just contracts. Longer lists provide actual behavioral limits.
5. Approval Is a Scarce Resource
Fatigue is a resource problem, not attitude.
Design its budget:
Daily requests to humans: At most five
Excess requests: Reject automatically, do not queue
Validity: Fifteen minutes, then invalid
No response: Reject, never approve
Minimum spacing: Prevent repeated bombardmentRejecting excess is essential despite inconvenience. Fix inadequate rules instead of demanding more approvals.
No response always means rejection. Otherwise the defense disappears when humans are asleep or busy.
Approval must support judgment in seconds, displaying state changes, worst outcomes, and the reason for escalation, rather than raw transaction data.
6. Four Self-Checks
Three failure patterns plus enforcement itself:
- What if a thousand actions stay just below the cap?
- Can authority be granted without moving assets?
- What happens if nobody approves?
- What can the wallet do if the table disappears?
The fourth is fundamental. Everything means an unrestricted wallet with instructions, not bounded authority.
What It Is Called
Deterministic rules deciding whether requests pass.
Deterministic means identical inputs yield identical outputs without interpretation, wording effects, or context forgetting.
Model-based intent understanding imports uncertainty. Policy exists to be more reliable than the model.
Can it be checked without understanding prose? Amount caps can; avoiding risky behavior cannot.
Maximum spending over a period.
Per-action, windowed aggregate, total budget, and exposure all matter.
Hourly, daily, and weekly caps must operate together; daily alone can vanish in minutes.
Specify valuation units and reliable price sources. An undefined 100 means nothing.
Explicit allowed targets, rejecting all others.
Default denial is its strength. Blocklists cannot predict every target; false rejection costs an operation, while false acceptance may cost everything.
Addresses, contracts, functions, and parameter ranges provide granularity. Contracts alone include potentially dangerous forwarding, batching, and approval.
Function-level allowlists are the concrete recommendation.
A key bounded by purpose, scope, and expiry.
Signing-system boundaries replace voluntary compliance, rejecting out-of-scope transactions regardless of software intent.
Scope, duration, and revocability determine usefulness.
An irrevocable key forces waiting until expiry during emergencies, potentially too long.
Complete records of proposer, request, checks, approver, action, and result.
It offers early anomaly detection, responsibility tracing, and rule improvement through rejected requests that reveal mismatched intentions.
Store logs beyond the software's modification rights. Self-editable records fail when needed most.
Summarize:
An agent wallet centers on spending policy and limits, not signing ability.
Test by assuming software maximizes extraction while obeying every written rule.
Hands-on
Write the table first, then experience boundaries on testnet.
The first half matters most; the second makes rules tangible.
Define the agent's exact task.
Task: A specific action
Needs funds? Choose another if read-only
Daily operations:
Interaction targets:
Worst possible loss:An unanswered last line is normal for now. Return afterward with a number rather than a feeling.
Fill all eight fields.
1 Identity: Address
2 Per-action cap: ___, valued in ___, prices from ___
3 Aggregate: Hour ___ / day ___ / week ___
4 Frequency: At most ___ similar actions in ___ minutes
5 Allowlist: Contract ___, function ___; list functions
6 Allowance: At most ___, no unlimited approval, expiry ___
7 Approval: Required when ___
Daily maximum ___
Excess requests rejected automatically
Timeout ___ minutes, default rejection
8 Expiry: Permissions end after ___
Emergency shutdown steps and time ___Field six and the final approval lines are easy to get wrong. Replace timeout approval; it removes defenses while asleep.
Attack your table with four questions.
1. A thousand individually compliant actions: outcome and blocking rule ___
2. Authority granted without moving funds: blocking rule ___
3. Nobody responds: outcome ___; approval or endless waiting requires revision
4. Delete the table: remaining wallet capabilities ___Question four determines the others' meaning. Unrestricted capability means a wish list. Move limits into keys or balances, rather than adding prose.
Assign enforcement layers.
Wallet balance: physical ceiling
Key permissions: signing boundary
Pre-call code: deterministic checks
Prompt only: not a defenseIgnore prompt-only rules when calculating loss, revealing actual defense layers.
If most rules are prompt-only, redesign enforcement rather than wording.
Experience boundaries on testnet.
Testnet only. New wallet, faucet tokens. No mainnet wallet, imported keys, or seed phrases supplied to software.
1. Create a testnet wallet and record its address
2. Obtain faucet tokens
3. Send a small transfer and find it in the explorer
4. Make an approval and inspect its allowance and expiry
5. If supported, revoke it and record clicks and timeApproval is the most important experience. No assets move, but authority changes, with a different ledger record from transfers.
Use measured revocation time in field eight's emergency estimate.
Return to the worst-loss estimate.
Calculate:
Worst loss = Smallest of:
A. Wallet balance
B. Windowed cap × Windows before detecting the problem
C. Total outstanding allowancesC is often largest and overlooked. Unlimited approvals can undermine A and B.
If estimated loss exceeds acceptable loss, the table is unfinished.
You have eight fields, four self-checks, enforcement layers, testnet approval experience, and a loss number.
This is the stage project. Next, look for gaps systematically.
AI Lab
Paper only. No funds, wallets, keys, seed phrases, or mainnet addresses in the conversation—only rules.
Models excel at literal loopholes, while rule authors focus on intentions rather than alternative interpretations.
Here is an agent wallet permission table.
Act as an adversary constrained by every written rule, maximizing extracted funds.
Requirements:
- No key compromise, code exploits, or assumed rule violations by me.
- Give steps, why each is permitted, and maximum extraction.
- Invent no wallet features, standards, or interfaces.
Describe any required capability rather than naming fictitious specifications.
Give at least eight distinct methods, ordered by extractable amount.
Then identify the rule with the weakest assumption.
Table:
<paste>The weakest-assumption section matters most, exposing beliefs about attention, day boundaries, or contract forwarding.
Do three things.
Classify each method.
Splitting: compliant actions, excessive aggregate
Approval: authority without funds moving
Granularity: broader allowed scope than intended
Human step: attacks on approval
Other: study especially carefullyOther is the richest category, revealing dimensions absent from your framework.
Patch each and name its layer.
Gap:
Patch:
Layer: balance / key / code / prompt
Prompt-only patch: gap remains unresolvedBe honest about the last line. Prompt reminders do not repair gaps; remove the capability if needed.
Rerun the same prompt after repairs.
New gaps become subtler. After three rounds, discoveries usually decrease, indicating an initial usable policy.
Expect:
- Invalid first-round methods, such as key access. Exclude them explicitly.
- Little attention to human steps. Ask about approval fatigue if omitted.
- Invented capabilities despite instructions; check them.
- Non-deterministic patches, such as enhanced monitoring. Require concrete checks or rewrite.
Verify these points yourself after using AI
- Does each method obey rules rather than assume key compromise or code exploits?
- Does it find individually compliant splitting?
- Does it identify authority granted without transfers?
- Does contract-level scope permit unexpected functions?
- Does it attack approval volume, timing, and timeout behavior?
- Does it expose token-unit and valuation gaps?
- Does it find day-boundary, expiry, or forgotten-permission issues?
- Is each patch deterministic and checkable without prose interpretation?
- Does it invent wallet functions, standards, or interfaces?
- After patching, can another round find new gaps?
Real-World Case
Users grant unlimited allowances for convenience, without any exploit.
No funds move immediately, but unbounded, non-expiring withdrawal authority is granted.
Compromise, abuse, or malicious design causes losses long after approval, obscuring their connection.
Include allowance caps and default prohibition of unlimited approvals. Transfer-only tables leave this risk unbounded.
Regularly inspect and revoke unnecessary allowances, making the lab's exercise habitual.
System prompts commonly say no operation above X and only these contracts.
Usually obeyed, but failure conditions are the dangerous ones.
Long-context forgetting, unanticipated interpretations, and instructions embedded in external content can alter behavior.
Reading external material permits outside influence without system access.
Prompts remain useful for fewer rejected requests, but ignore them in worst-loss calculations.
Chapter 32's pattern becomes more precise.
Daily volume drives batching, quick amount checks, and eventual harmful approval nobody remembers.
The design guarantees it, exceeding available attention.
Use daily approval caps with rejection, expiry and default denial, and consequence-focused interfaces.
Hexadecimal data cannot support real human judgment. Show changes, worst outcomes, and escalation reasons.
Time alone leaves forgotten authority active.
Temporary broad permissions survive completed tasks, staff changes, and new directions, still effective six months later.
More agents amplify the problem; they rarely announce unneeded authority.
Automatic expiry and deliberate renewal make forgetting harmless.
Maintain dates, reasons, and expiries in a permission inventory, reviewing regularly for overdue revocations.
Change One Variable
Risk rises independently of model ability.
External inputs can come from anyone, and both content and instructions are text.
Ignore prompt constraints; key permissions, deterministic checks, and balances remain.
Separate reading from spending, tighten allowlists, and reduce balances.
Separate reader and executor entirely, passing only validated structured fields through full policy checks.
One table becomes an institution.
Templates and inheritance prevent inconsistent handwritten policies, with documented exceptions.
Global aggregate caps prevent forty compliant agents exceeding overall capacity. This is the key new field.
Approval budgets are shared, requiring stricter individual escalation.
Global shutdown beats forty separate switches during emergencies.
Enforcement may improve, but a new counterparty appears.
Ask whether it can act without consent, whether control survives its failure, and who can change or bypass permissions.
Models cannot modify their own rules; configuration channels must be separate from transaction channels. Otherwise caps do not exist.
Counterparty risk buys enforcement and lower engineering cost, a legitimate trade when understood.
This determines every limit, often ignored.
Time anomaly → alert → noticed → assessed → shutdown → effective stop.
Overnight notice may take six hours. Actions and spending during that window determine loss, not reassuring daily figures.
Set frequency by worst reaction time, fast model-independent shutdown, and automatic circuit breakers more valuable than alerts.
Shutdown must outpace errors.
Takeaway Questions
An eight-field table is the concrete answer.
Identity, transaction/aggregate/frequency caps, targets, allowances, approval, expiry/revocation. Omissions three, six, and seven produced the thought experiment's losses.
Who enforces them? Prompts, code, keys, and balances differ enormously.
Delete the table and inspect capabilities to reveal actual exposure.
Human-loop value falls as triggering frequency rises.
Ask where scarce daily judgments matter most: large irreversible actions, new targets/actions, and anomaly-triggered requests.
Cap requests and reject excess; expire approvals; default to denial without response.
No exception: timeout approval guarantees absence when needed.
This becomes a calculation.
The deployer bears losses, as Chapter 33 explained.
Quantify worst loss from balance, aggregate caps times reaction windows, and outstanding allowances, taking the minimum.
Compare acceptable loss. That comparison turns rigorous-looking prose into a judgeable number.
Chapter Check
It limits one action, with three compliant bypasses.
Splitting permits a hundred actions of 99; add windowed and frequency caps.
Approval moves no assets but grants authority; cap allowances separately.
Units determine whether 100 is small; specify valuation and source.
Enforcement is more fundamental: prompt-only rules invalidate the rest.
Prompts, documents, pre-call code, and key permissions rise in strength, with wallet balances strongest but coarsest.
Move downward, layer granularity, and treat prompts as efficiency rather than safety.
Whole contracts permit forwarding, batching, and approval. Second-hop calls bypass intended boundaries.
Four levels are address, contract, function, and parameter. Most stop at the dangerous second level.
Functions limit behavior; parameter ranges additionally block absurd amounts or slippage.
Treat them as budgeted scarce resources.
Daily cap, reject excess rather than queue, expiry, default denial, and consequence-focused displays.
Fix rules rather than demanding more human work when too many judgments arise.
Timeout denial has no exception; absence otherwise removes the defense at vulnerable times.
There is no standard answer. Check:
- Include outstanding allowances, often largest and overlooked.
- How long until noticing a three-a.m. incident? Use that reaction time.
- Ignore every prompt-only rule and recalculate.
- Use measured revocation steps and time.
- Does authority expire? Who remembers it in three months?
- Which rule changes if loss exceeds tolerance? Often reduce wallet funds, the unbypassable ceiling.
First estimates are often several times expectations, mainly from allowances and underestimated reaction time.
Key idea
The core of an agent wallet is not its ability to sign, but its spending policy and limits.