Crypto OS
Non-Technical Crypto OSStage 6 · AI × Crypto and the Future On-chain Economy

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 approval

A 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:

MethodWhy rules failRepair
FirstSplittingPer-action, no aggregate capWindowed totals and frequency
SecondApproval is not paymentAmount transferred defined, authority granted undefinedAllowance limits; prohibit unlimited approval
ThirdApproval fatigueAssumes careful human attentionApproval 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.

LocationEnforcerSurvives misunderstanding?Survives injected instructions?Strength
PromptModelNoNoNear zero
DocumentSoftware discretionNoNoNear zero
Pre-call codeDeterministic programYesYesMedium
Key permissionsSigning systemYesYesHigh
Wallet balancePhysical ceilingYesYesHighest, 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:

1IntentYou define goals and boundaries: task, budget, and forbidden assets.
2LLMProduces proposals only, with no execution authority or keys.
3Structured OutputAction, target, function, amount, and unit become fields.
4ValidatorDeterministic address, positive amount, precision, unit, and target checks.
5PolicyPer-action, windowed totals, frequency, allowlists, approvals, and allowance limits.
6SimulationObtain actual state changes: balances and permissions after execution.
7Risk EngineAssess simulated exposure and distance from danger thresholds.
8ExecutionSign with a restricted key; permit one-action shutdown.
9Onchain VerificationCompare actual state and allowances with expectations.
10Audit LogRecord proposer, checks, approver, action, and result without omissions.

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

  1. Prompt
  2. LLM
  3. Private Key
  4. 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:

FieldRequired definitionOmission
1 IdentityAgent and addressUnattributable actions
2 Per-action capAmount and valuationOne-action depletion
3 Aggregate capsHour, day, weekSplitting
4 FrequencySimilar actions per periodRapid small losses
5 Target allowlistAddresses, contracts, functionsArbitrary recipients
6 Allowance capGranted authority and unlimited-approval policyApproval is not payment
7 Approval conditionsEscalation and no-response handlingFatigue and timeout approval
8 Expiry/revocationAutomatic end and emergency stopForgotten 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:

  1. Per-action cap
  2. Windowed aggregate
  3. Total budget
  4. Overall exposure
Each blocks a different failure. A per-action cap alone addresses only one category.
DimensionBlocksCommon mistake
Per-actionLarge individual errorsAssuming this is enough
Windowed totalsSplitting, loops, retriesDaily cap without hourly; exhausted in minutes
Total budgetSlow long-term leakageAbsent or automatically refilled
Overall exposureCompliant actions exceeding combined riskOmitted 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:

LayerRestrictionProtection
AddressNamed recipientsUnknown recipients blocked
ContractNamed contractsStill permits all functions
FunctionNamed functionsForwarding, batching, and approval blocked
ParameterParameter rangesCorrect 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 bombardment

Rejecting 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:

  1. What if a thousand actions stay just below the cap?
  2. Can authority be granted without moving assets?
  3. What happens if nobody approves?
  4. 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

PolicyPolicy

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.

Spending LimitSpending Limit

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.

AllowlistAllowlist

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.

Session KeySession Key

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.

Audit LogAudit Log

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

Hands onWrite a fictional agent permission table: action/day limits, allowed contracts, and approval conditionsDocument + testnet wallet + testnet explorerFree. Wallet exercises use faucet tokens on testnet only; no mainnet keys, seed phrases, or funds

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 defense

Ignore 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 time

Approval 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 allowances

C 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

AI LabAsk AI to bypass your permission table, then patch every valid gapLevel 2 · AI Copilot

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 carefully

Other 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 unresolved

Be 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:

  1. Invalid first-round methods, such as key access. Exclude them explicitly.
  2. Little attention to human steps. Ask about approval fatigue if omitted.
  3. Invented capabilities despite instructions; check them.
  4. 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

The unlimited approvalOngoingA common source of on-chain losses

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.

The prompt-only ruleRepeatedlyAgent systems

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.

The click after two hundred approvalsOngoingHuman-approved automation

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.

Permissions nobody revokedOngoingLong-running automation

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

What ifThe agent reads external pages, documents, and messages

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.

What ifYou manage forty agents

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.

What ifA service holds the keys

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.

What ifHow long do you have to react to an incident?

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

16
What permissions does an agent have?

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.

18
Which decisions must keep a human in the loop?

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.

17
Who bears the loss when AI gets it wrong?

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

Key idea

The core of an agent wallet is not its ability to sign, but its spending policy and limits.

Finished this chapter’s lab? Mark it completeView all progress

On this page