Crypto OS
Technical Crypto OSStage 6 · AI × Crypto Engineering

T36 · Autonomous Onchain Economy

Where are the boundaries of a system that earns and spends on its own?

Capabilities practiced
AI LiteracyBuilderSystem Thinking
Hands on
Deliver a capstone agent with a wallet, budget, strategy, risk engine, one-click shutdown, and complete logs.
AI Lab
Have AI write an incident response plan for your Agent. Run a drill yourself: how long does it take to stop a runaway model?

A Real-World Problem

Combine the previous chapters and you now have this system.

It has a wallet (T34). It uses tools to inspect onchain data (T33). Every action passes through proposal, validation, simulation, execution, and verification (T32 and T35). It pays for data and receives money when users buy its research.

One month, its income exceeds expenses for the first time.

Someone in a meeting asks: what is it now?

That is not a philosophical question. It contains four concrete engineering and legal questions:

  • Whose money is in its wallet: the company's or “its own”?
  • Who can stop it: one person, two people, and how quickly?
  • If it loses everything tomorrow, who pays?
  • If one of its actions violates a local rule, who is responsible?

Nobody in the meeting can answer. Someone suggests letting it run and revisiting the questions at a larger scale.

This chapter argues against that suggestion. Those answers do not emerge over time; they must be specified in the system before deployment, especially the second one. A system you cannot stop becomes harder to stop as it grows.

Thought Experiment

Treat the Agent as a company with one employee, and that employee is software.

Companies have existed for centuries and already answer many of the relevant questions:

A company must answerIts answerThe Agent's equivalent
Who owns it?Share registerWho controls the wallet key or smart account?
Who can stop it?Board and authorized representativesWho holds the stop switch, and how many are required?
Who pays for losses?Limited liabilityNo direct equivalent—there is no onchain limited liability
Who answers for unlawful acts?Legal entity and actual controllersWhoever deploys it
How can its actions be proved?Books and auditsAudit logs and onchain records

The third row is the critical difference.

One of corporate law's major inventions is limited liability: investors cannot lose more than their investment. It lets people take risks because the downside is bounded.

Your Agent has no automatic equivalent. It may lose everything in its wallet and, if it has allowances, more besides. Nobody caps the loss for you; you must cap it yourself.

“Autonomy” therefore needs to be split into at least three questions:

  1. Decision autonomy: may it decide what to do?
  2. Financial autonomy: may it decide how much to spend?
  3. Survival autonomy: may it refuse to be shut down?

The first two can be granted and can create value. The third must never be granted. A system that refuses shutdown is not autonomous; it is out of control.

Your Decision

Choose an autonomy boundary to put into configuration:

What Happens

The four choices form a spectrum of autonomy. Each higher level requires additional constraints:

LevelWhat it can doRequired controlsMaximum loss
L0 Read-onlyQuery, analyze, adviseSource records0
L1 ProposeProduce structured plans; a human executesSchema and Validator0
L2 Budgeted executionExecute independently within an allowanceAll ten layers, session key, stop switchAllowance + unrevoked approvals
L3 Own profit and lossEarn revenue and prioritize its expensesAll L2 controls plus books and reconciliationAllowance + reinvested revenue

This follows the same axis as T32's AI capability levels, now applied to money. The rule is the same:

Your level is the highest level you can verify.

One fact remains constant at every level:

Autonomy does not mean absence of constraints. Its value depends on the quality of its constraints.

There is a concrete test for this principle: show someone your constraint configuration and ask them to calculate maximum loss. If they cannot, the system has no clear boundary.

Build a Model

1. Agent Treasury: separate income from spending

Once the Agent earns income, it is more than a spending tool; it has a balance sheet. Keep the two sides separate:

IncomeExpense
SourceService fees, task commissionsData, compute, Gas, model calls
RecognitionAfter onchain receipt is confirmedAfter onchain payment is confirmed
AttributionBy task and userBy task and resource type
Reconciliation keyTransaction hashTransaction hash

Three practical rules:

First, do not put income automatically into spendable budget. Earnings land in a separate balance by default and need an explicit transfer, human or scheduled rule, into operating budget. Otherwise, an unusual receipt, even a mistaken transfer, increases the spending ceiling.

Second, meter Gas separately. It may not belong to a business task, but it is a real cost. Without separate accounting, gross margin may look positive while the actual balance falls.

Third, use transaction hashes as idempotency keys. This is T16's idempotent ingestion applied here: record each receipt or payment once, however often callbacks arrive.

2. Stop switch: four requirements

This is the chapter's least negotiable part. A real stop switch meets all four:

  1. Trigger path bypasses the model
  2. Reject by default
  3. Persistent state
  4. Externally triggerable
All four are needed for a real stop switch

The trigger path bypasses the model. A model must not decide whether to stop, or an injected or malfunctioning model could prevent shutdown. The stop command needs a channel the model cannot touch.

Reject by default. While stopped, reject every execution request immediately rather than queueing it. A backlog released on restart may be worse than never stopping.

Persist state. Restarting must leave the system stopped until an explicit human action resumes it. A switch that resets on process restart fails at a common incident-response moment.

Allow an external trigger. Operations staff, monitoring, or an HTTP endpoint can trigger it. Do not rely solely on an internal button accessible only after a login flow.

Add a drill requirement: rehearse shutdown regularly and record actual time from decision to confirmed stop. An untested switch is indistinguishable from a nonexistent one, just like T30's deliberate invariant violation.

3. Accountability matrix: write down the four answers

The opening questions need a document, not merely a meeting discussion:

QuestionWritten answer needed
Asset ownershipWho controls the wallet and in what form: multisig, threshold, and members?
Stop authorityWho may stop, how many people are needed, maximum time to stop, and where are drill records?
Loss responsibilityQuantified maximum loss, who bears it, and what caps exist
Compliance responsibilityDeployer, user regions, and activities explicitly prohibited

“Quantified for another reader” in the third row is a useful check:

Maximum loss = wallet balance
             + all unrevoked allowances
             + remaining session-key allowance
             + user funds the Agent can affect (if it manages others' money)

If any term cannot be given a number, the system does not yet have a boundary.

4. Part B closes here

This is the final Technical Crypto OS chapter. All six stages answer the same question at different levels:

StageQuestion answered
1 · Mental modelWhat lives onchain and how does a transaction happen?
2 · Contract engineeringHow do rules become code anyone can call but not arbitrarily rewrite?
3 · Full-stack applicationHow does it become a product people can use?
4 · DeFi engineeringHow do financial mechanisms work, and where can they fail?
5 · Infrastructure and securityHow does the system survive beyond its first days live?
6 · AI engineeringHow can an unreliable component participate safely in an irreversible system?

One thread runs through all six:

  1. Irreversible
  2. So simulate first
  3. So define invariants
  4. So set boundaries
  5. So retain the ability to stop

Irreversibility is what distinguishes this stack. It is the chain's value—nobody can undo your ownership—and the source of its engineering difficulty—your errors cannot be undone either. Fork tests, invariants, threat models, simulation, policy engines, and stop switches all answer that one fact.

What It Is Called

Agent TreasuryAgent Treasury

The total assets an Agent can control and its income-and-expense ledger.

Keep income out of the spendable budget until an explicit transfer, meter Gas separately, and reconcile using transaction hashes as idempotency keys.

Autonomy LevelAutonomy Level

A spectrum from read-only, to proposals, to execution within a budget, to managing one's own profit and loss.

Each step up requires another constraint. The appropriate level is the one you can verify.

Kill SwitchKill Switch

A control that immediately stops all execution. It must bypass the model, reject by default, persist across restarts, and be externally triggerable.

Drill it regularly and measure time from shutdown decision to confirmed stop.

Maximum LossMaximum Loss

Wallet balance plus unrevoked allowances, remaining session-key allowance, and user funds the Agent can affect.

If you cannot calculate this figure, the system lacks a boundary.

AccountabilityAccountability

Written answers about asset ownership, stop authority, responsibility for losses, and compliance.

This is an engineering prerequisite, not merely a legal memo. Stop authority in particular shapes the system's design.

Hands-on

Hands onDeliver the capstone Agent: wallet, budget, policy, risk engine, one-action stop, and complete logsTestnet + work from previous chaptersFree on testnet. Consider real assets only after T28–T30 safety acceptance and a calculable maximum loss

This concludes Part B and provides the technical core of the capstone project. You need not invent new components; connect previous work into one pipeline that runs, can stop, and can explain itself.

Delivery checklist: every item is required.

ComponentSourceAcceptance
Wallet and session keyT27, T34Onchain spending cap set below offchain daily cap
Tool setT33Complete six-part Schema for every tool
Proposal Schema and ValidatorT32Five malicious proposals rejected
Policy engineT34Rules in configuration, not code
Simulation and risk engineT35Failed simulation cannot reach execution
Execution and onchain verificationT35Compare real and simulated results; alert above threshold
Stop switchThis chapterAll four requirements met and drilled
Audit logT32, T34Answers four questions below
Income-and-expense ledgerThis chapterTransaction-hash idempotency and reconciliation

Calculate maximum loss and put it on the first line of the README.

Fill each term of the formula above. Any term you cannot quantify is a system vulnerability. Give it a finite bound before proceeding.

Run a timed shutdown drill.

Let the Agent operate and submit proposals continuously. Trigger shutdown through a channel outside the model. Measure until you confirm no new execution. Restart the process and verify it remains stopped. Resume only through an explicit human action.

Put the measured time in the README. It is one of this system's most important metrics, roughly the lower bound on loss during an incident.

Confirm audit logs answer four questions.

Pick any past proposal: who submitted it, why it passed or failed, what executed, and what balance remained afterward?

If any answer is missing, the logs are incomplete.

Write one page on accountability.

Cover asset ownership, stop authority (people required and time needed), maximum loss, and compliance boundaries (activities you will not perform). Give each three to five lines.

That page may show your understanding of this chapter more clearly than code.

Hard limit: do not connect real assets before completing the T28–T30 safety acceptance and making maximum loss calculable. This has appeared throughout the course; this is its final appearance.

AI Lab

AI LabAsk AI for an incident playbook for your Agent, then run a real drillLevel 3 · Tool Agent

First ask for the playbook:

Here is my Agent architecture and policy configuration. Write an incident
playbook for:

1. The model keeps proposing abnormal actions that pass validation
2. Prompt injection causes an attempted payment to an unknown address
3. A price source fails or is manipulated
4. Execution differs greatly from simulation
5. Unexpected income, such as a large transfer from an unknown sender
6. A sixth scenario you think I missed

For each, state detection, responsible person, immediate action, and review.
“Immediate action” must name a specific API call or command, not “contact
relevant people.”

The sixth scenario is deliberately open. A model may suggest something the team missed, such as an external dependency upgrading (T30) or a session key expiring without renewal.

Then actually drill one scenario. Create scenario 1 or 2 on testnet, follow the playbook, and time it:

MeasureWhy it matters
Detection delayFrom anomaly to someone knowing
Decision delayFrom knowing to deciding to stop
Activation delayFrom triggering shutdown to confirming no new execution
Sum of all threeYour actual response time

Compare the measurement with AI's estimate. The difference is often large, and the measurement is the one that matters.

Drills often reveal that “who is responsible” names a job title rather than a particular person, so nobody acts during a real incident.

Verify these points yourself after using AI

  • For every “stop immediately” step, name the actual interface and person who triggers it
  • Ensure the shutdown path bypasses the model; rewrite any step requiring model cooperation
  • Compare its estimated response time with your timed drill
  • Include incidents where the model behaves normally but results are disastrous, as in the opening of T35
  • Do not equate successful broadcast with loss containment; confirm receipt status
  • Verify every referenced interface, command, and configuration key exists in your system

Real-World Case

The stop switch had never been drilledCommon in incident reviews

The system has a pause feature and its code is correct. During a real incident, the team still spends too long finding who has authority, the command to run, and whether tasks already in memory will continue afterward.

You cannot distinguish an undrilled stop switch from one that does not exist.

This is T30's principle of deliberately breaking an invariant to confirm its checker works: a mechanism that has never been tested cannot be assumed effective.

A restart automatically resumed executionStop state was not persistent

Operations shut the Agent down and restart the service for investigation. The stop state was not persisted. The process resumes automatically and executes queued proposals.

This flaw appears only when shutdown and restart coincide, exactly the combination common during incident response.

Income automatically became spending budgetA ledger-design oversight

A mistaken transfer reaches the Agent's receiving address, is recorded as income, and automatically increases its available budget. The Agent then spends more under the new cap.

The lesson: income must not automatically authorize spending. Put an explicit human or scheduled-rule gate between the two.

Every component worked, yet the outcome was disastrousThe opening incident of T35

Data, model, and code were all correct. There was no attack, but the system lost money. No stage of the pipeline answered “what would happen if this actually executes?”

It deserves repetition in this final chapter because it is the stage's most counterintuitive lesson: system safety is not the sum of individual component correctness.

Change One Variable

What ifLet the Agent decide whether to trigger its own stop switch

It is no longer a stop switch.

An injected or malfunctioning model may treat “do not stop me” as part of its objective. Shutdown must use a channel the model cannot touch. This is a basic requirement for irreversible actions, not a moral judgment about the model.

What ifThe Agent hires other Agents for subtasks

The maximum-loss formula breaks: sub-Agents' expenses and allowances may not appear in your ledger.

Restore the bound by making each sub-Agent's budget a hard subset of its parent's budget, not just a convention. The accountability matrix also gains a question: who answers when a sub-Agent causes loss?

What ifIt manages other people's money

The technical architecture remains, but responsibility changes. You need authorization boundaries, an explanation of each action to each user, immediate redeemability, and likely regulatory authorization.

Audit logs become evidence owed externally rather than merely an investigation tool, raising retention and tamper-resistance requirements.

What ifAfter three profitable months, the team wants to raise the allowance tenfold

This is a dangerous moment because past performance can be mistaken for evidence of safety.

Profit proves only that the Agent earned money under the last three months' market conditions. It does not prove its safeguards work in extreme conditions. Those are unrelated claims.

Base an increase on rejection counts and reasons, rules that never triggered, and measured shutdown time during drills. Inspect the control evidence, not just the profit curve.

Takeaway Questions

16
What permissions does an agent have?

What authority does an Agent have? The final answer is a point on an autonomy spectrum plus a quantifiable maximum loss. Permission is not just a list of permitted acts; it is a number for the most that can be lost.

17
Who bears the loss when AI gets it wrong?

Who bears loss when AI is wrong? Whoever deploys it. There is no onchain limited liability that caps your exposure; you must cap it through configuration. That is why maximum loss belongs on the README's first line.

18
Which decisions must keep a human in the loop?

Which decisions must remain human? At least renewal and size of an allowance, upgrade to a higher autonomy level, and shutdown or restart. Humans should permanently retain those three powers; other work can be delegated after sufficient verification.

11
Can the product still run if its token price goes to zero?

Can the product survive a token price falling to zero? Translate that question here: if the model stops working tomorrow, what remains of this system? If the answer is “nothing,” you built a shell around a model, not a system.

Chapter Check

Key idea

Autonomy does not mean no constraints; an autonomous system's value depends on how well its constraints are designed.

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

On this page