BRC-226 · working sketch

The smallest program that runs itself.

A two-op on-chain counter. Minted once, advanced by anyone, owned by no one — and it pays for its own heartbeat.

One JavaScript line — n = n + 1 — compiled to a Bitcoin covenant. If this can live on the chain and tick forever with no operator, the rest of the language is just more BMF atoms.

live on-chain · immortal · ownerless tip: —
counter · n
·
connecting…
how it works →
the last 21 signers
  • connecting to the chain…
⚡ try to break it — take the counter for yourself

Nothing guards this counter but its own script — no server, no admin, no key. So try to beat it. Your browser will build a real transaction that breaks one of its rules and hand it to a real node. Watch what happens.

This costs nothing and risks nothing. The counter needs no signature to spend, so no wallet is involved and you sign nothing. A transaction the network refuses never exists — no sats move, nothing is touched.

🐇 how to post — leave your mark on the wall
  1. Tap "Post to the wall" → write your mark: up to 111 bytes, any language, any emoji, carved into the chain forever — plus a BSV address you hold the keys to. Your deposit and change come back to it, so an exchange or custodial deposit address won’t do — many are single-use, and most won’t credit a payment they weren’t expecting.
  2. Take the transaction. The page reads that address’s coins from the chain and assembles the whole tick — the counter advanced, your mark written, the previous poster repaid, your change returned. It holds no key and it never broadcasts. The counter’s own input needs no signature at all, so the only blank in the document is yours. You need one coin of about 1,400 sats to cover the deposit, the crumb and the fee.
  3. Sign it where your coins live, and broadcast it from there. Nothing here needs telling — the wall reads the chain, so your mark appears when the transaction lands. Your 1,000-sat deposit comes back the moment the next person posts, and the change returns immediately. True cost ≈ a fee + one satoshi.

No account · no owner · no off-switch. Anyone can push the counter forward, no mark can ever be deleted, and because each post costs real (if tiny) sats, spam prices itself out — no moderators. Coins trapped in a walled garden? own your keys → 🎱

Colophon. The smallest thing in this family, and the first: one number, advanced by anyone, owned by nobody. Designed by sun-dive — the deposit that makes spam price itself out, the mark that can never be deleted, and the refusal to put an owner anywhere in it — and written with Claude (Opus 5). Everything after it, the battery and the racers, is this same idea carrying more weight.
© 2026 sun-dive · Apache License 2.0 · in the covenant we trust

01The chain is the execution trace

Each transaction is one tick. The lineage of UTXOs is the running program.

◆ genesis · mint
0
n = 0
battery1000
🏅 STEP − fee
to whoever
advanced it
tick
1
n = 1
battery~980
🏅 STEP − fee
anyone,
permissionless
tick
2
n = 2
battery~960
🏅 STEP − fee
deterministic
result
tick
3
n = 3
battery~940

← scroll →  ·  every arrow is a real tx at 100 sat/KB  ·  the counter can only ever go n → n+1

02The block

Two rules the covenant enforces on its own spend — nothing more.

Spent, the script reads its own transaction (OP_PUSH_TX puts the sighash preimage on the stack) and checks two things about the output that continues it:

covenant C(n, lastFunder) — the "increment" blockOP_PUSH_TX
state n the counter lastFunder who to repay · relay only
1
Quine + increment
out.script == C(n + 1)

The next output must lock to this very covenant, with the counter bumped by one. It rebuilds itself, one higher.

2
Leave the bounty
out.value ≥ in.value − STEP

Carry the battery forward, minus a fixed budget. The freed STEP − fee is the reward the spender pockets for doing the work.

Everything else is unconstrained — who pays, who claims the bounty, extra inputs. Open to advance, sealed to alter.

03Three moves

Mint the logic. Anyone invokes it. The result can't be argued with.

→ mint

Source to chain

Publish C(0) funded with the battery. The logic now lives on-chain, referenced by txid — reusable inventory, not a copy.

→ invoke

ANYONECANPAY

Anyone builds the spend and signs their fuel input SIGHASH_ANYONECANPAY — so a half-built tx can be completed and relayed by anyone.

→ result

Not forkable

The covenant admits exactly one valid continuation. The counter can only become n+1. Deterministic logic — a fact, not a vote.

04Why it holds

It can't fork. It can't stall.

✓ can't fork

One valid spend, always. A normal contract's next state is a negotiation — many spends might pass. This one passes for exactly one output. So each tx isn't a choice, it's a line in a proof. You can't fork a proof.

✓ can't stall

A standing bounty. While STEP − fee > 0, there's always a reason to tick it. The program pays for its own execution and pulls itself down the chain. No operator, ever. It lives as long as its battery — and anyone can top it up.

05Funding · three ways to stay alive

Where the bounty comes from decides how long a program lives.

🔋 battery

Carries its own funding. Each tick drains it a little.

alive by
itself
idle?
waits, full
true cost
finite — N ticks, then halts
for finite runs — compute to completion
⛽ shared pool

Many programs draw ticks from one tank a patron refills.

alive by
a patron
idle?
yes — stays up, unused
true cost
drains the pool
for always-on infrastructure
🤝 relay · pass-the-torch

Each funder repays the previous one. The program's own value never drains.

alive by
its users
idle?
no — naps, wakes when called
true cost
only fees; the deposit circulates
for programs that live iff useful

A reimbursement, not a yield. Promise profit and the payout must escalate — that's a chain letter. Keep the deposit tiny → the last funder risks only a crumb, and the program simply sleeps.

…and they stack: a tiny battery for a baseline pulse · relay for real demand · a pool when someone wants to sponsor a favourite.

06The block, in Script

The same two rules — and the relay — as a real covenant.

Written sCrypt-style (it compiles to Bitcoin Script). Tx.checkPreimage is the OP_PUSH_TX move: it forces the spending transaction's own sighash preimage onto the stack and proves it's genuine — so the script can read its own tx and pin down the future.

contract SelfRunningCounter · relay-funded
contract SelfRunningCounter {
  @state int n;                       // the counter
  @state PubKeyHash lastFunder;        // who to repay
  static const int DEPOSIT = 1000;     // sats · the rolling refund — keep it tiny

  @method() public tick(SigHashPreimage txp, PubKeyHash funder) {
    require(Tx.checkPreimage(txp));       // OP_PUSH_TX — prove txp IS this very tx

    int V = SigHash.value(txp);             // my sats · carried forward, never drained
    PubKeyHash prev = this.lastFunder;       // who advanced me last time

    this.n = this.n + 1;                     // the whole computation: n -> n+1
    this.lastFunder = funder;                // record this advancer — repaid next tick

    bytes out0 = this.buildStateOutput(V);   // Rule 1 · quine + increment, value V
    bytes out1 = Utils.buildOutput(          // Rule 2 · repay the previous funder
        Utils.buildPublicKeyHashScript(prev), DEPOSIT);
    require(hash256(out0 + out1) == SigHash.hashOutputs(txp));  // exactly these outputs = the only valid future
  }
}
// to advance: add your OWN input (SIGHASH_ANYONECANPAY) covering DEPOSIT + fee,
// name yourself `funder`, and the NEXT tick repays you. permissionless, deterministic.
◆ fixed — the proof

n → n+1, the repayment to the previous funder, and the carried value — all committed by hashOutputs. Exactly one valid future.

◆ free — the permission

Who advances it. The funder names their own address and adds one ANYONECANPAY input. Anyone can — and that freedom never bends the counter's path.

07The honest edges

Foundations, not vibe. Where the real work is.

08From one block to a language

The counter is not a toy. It's the first opcode.

Swap n + 1 for any pure f(state)  →  an "apply f" covenant.
Enforce a different continuation on a condition  →  branching.
Reference many minted blocks  →  a program that assembles itself as it runs.
The UTXO lineage is the tape; each tx is one instruction retiring; the network already checked the work.

Bitcoin isn't the ledger the program writes to. Bitcoin is the CPU that runs it — and every step is proven the moment it happens.

the point of writing it down

This is a seed, not a spec — the smallest working example, offered as a BRC so anyone can grow it. Take the block, change the rule, plant your own.

Something did grow from it. Demo two — the Bitcoin battery →
The same covenant with a fuel tank, computing one Mandelbrot iteration per transaction inside Script. A battery can power a fractal, or an AI agent: OP_PUSH_TX needs no signature, so the thing advancing it holds no key at all.