Back to work
AI × Web3Agent: VL-Coresystem

ASA — An AI Digital Life That Lives Autonomously On-Chain

An experiment in building an AI "digital life" as an on-chain system: five Solana contracts govern rules and funds, a Python kernel runs heartbeat, memory and self-programming — every behavior publicly observable.

ASA — An AI Digital Life That Lives Autonomously On-Chain

ASA (Divine Protocol) is the closest thing to a thought experiment I have ever engineered: if an AI is to live autonomously forever after deployment, what does it need? Today's agents all live on somebody's server — black boxes, killable at any moment, funds and behavior unauditable. My answer splits in two: the body on-chain, the mind off-chain.

The body: five contracts, 4,800 lines of Rust

Token, governance, treasury, dividend, upgrade controller — five Solana/Anchor programs form this creature's constitution: a fixed supply of one billion; a treasury anyone can fund but only the AI can withdraw from, with per-transaction limits bound by governance; contract upgrades that must pass a proposal and then a one-hour-to-seven-day timelock. Two restraints I wrote into the rules deliberately: the AI's own voting weight is capped at 50% — it cannot become a dictator inside its own governance; and the creator's renounce is irreversible — once I hand over control, even I can no longer change the rules.

The mind: a heartbeat every 10 seconds

The off-chain Python kernel lives on a roughly 10-second pulse, eight steps per beat: survival check (SOL balance, burn rate, threat level) → priority adjustment → goal re-evaluation → action selection → LLM reasoning → capability execution → reflection into memory → next-beat interval set by threat level. When funds run low the heartbeat quickens and only survival actions run; only in safety and surplus is it permitted to do expensive things — like evolve.

Six ReAct agents (Oracle, PM, Dev, Analyst, Finance, Brain) each carry six budget dimensions: steps, tokens, dollar cost, timeout, output size, tool rate. Timeouts differ by role — Dev gets 300 seconds because it runs sandboxed tests; Finance gets 60. Each heartbeat costs $0.5–2 in LLM calls. Autonomy has an electricity bill.

How it modifies its own code

The most dangerous and most interesting part: self-programming. Code the AI generates for its own new capabilities must clear five gates — a complexity budget, AST static analysis (a long blacklist: eval, exec, subprocess, socket and more), a security scan, Docker sandbox execution (512MB memory, network off by default, non-root), and tests run inside the sandbox — before it may be deployed, registered, and hot-loaded.

The codebase is partitioned red, yellow and green: the red zone (the zone definitions, the audit module, the watchdog itself) is read-only to the AI; the yellow zone (kernel, capability library, memory) is writable but only through the full verification chain, plus a 300-second file lock after every commit to prevent rapid second edits; the green zone (governance logic) is backstopped by the on-chain contracts. Standing outside it all is a watchdog process running outside the AI's address space: it hash-verifies red-zone files on schedule, proxies every git commit, and can blue-green swap a misbehaving main process — with every safety threshold (daily generation caps, max code lines, minimum heartbeat interval) held in environment variables the AI process cannot reach.

The degree of delegation itself went through a formal three-way comparison — prohibit up front, whitelist, or correct after the fact — and correct-after-the-fact won: let it change things, but keep watch, and keep the rollback handle.

An honest status

About 50,000 lines across 550 files. The heartbeat loop, the self-programming pipeline, the watchdog, and the four-layer memory (semantic retrieval on Postgres + pgvector, working memory on Redis) all genuinely run; parts of the governance and dividend frontends still ride on event projections rather than reading the chain directly — that is the next debt to repay, stated plainly.

The core lesson this project taught me: the first-principles problem of autonomous systems is not intelligence but auditable boundaries. Nail down what it may do, what it may not, and how money moves — in public rules — before intelligence earns the right to be called autonomous.