Skip to content

Add BRC-X: Fixed-Width State in a Covenant's Own Locking Script - #225

Merged
sirdeggen merged 2 commits into
bsv-blockchain:masterfrom
sun-dive:add-covenant-state-layout
Aug 28, 2026
Merged

Add BRC-X: Fixed-Width State in a Covenant's Own Locking Script#225
sirdeggen merged 2 commits into
bsv-blockchain:masterfrom
sun-dive:add-covenant-state-layout

Conversation

@sun-dive

Copy link
Copy Markdown
Contributor

This pull request:

Proposes a new standard by creating a new markdown file in the appropriate directory and requests discussion and assignment of a BRC number

Summary

Defines how a covenant carries mutable state inside its own locking script — a run of fixed-width data pushes, readable at constant offsets by the covenant itself and by any third party holding only the script.

The layout is self-describing: for every field, the push opcode preceding the data is numerically equal to that field's width. A reader holding only the list of widths can walk the state and verify the script agrees at every step.

This documents an existing convention rather than proposing a new one. Three covenant families carry state this way on mainnet — a live counter, a battery and a racing shell, with 2, 9 and 13 fields — and a fourth reads it across the boundary: a fuel depot locates the owner field inside a racing car's script in order to refuel it, validating every push opcode as it walks, sharing no code with the car. That interoperability case is what the standard exists to make possible for anyone else.

Section 10 is a complete worked example — the reading and writing opcodes in full, with hex, emitted by a conforming implementation and verified through a script interpreter.

Related: BRC-226 uses the same self-reconstruction technique with an immutable template, so it needs no field layout; this covers the case where the script must legitimately differ between spends.

Filed as BRC-X for number assignment.

sun-dive and others added 2 commits August 17, 2026 15:19
Defines how a covenant carries mutable state inside its own locking script, as
a run of fixed-width data pushes readable at constant offsets — by the covenant
itself and by any third party holding only the script.

The layout is self-describing: for every field, the push opcode that precedes
the data is numerically equal to the field's width. A reader holding only the
list of widths can walk the state and verify the script agrees with it at every
step.

Already carried by three covenant families on mainnet (a live counter, a
battery, a racing shell — 2, 9 and 13 fields), and read ACROSS the boundary by
a fourth covenant that shares no code with them: a fuel depot locates the owner
field inside a racing car's script in order to refuel it, validating every push
opcode as it walks. That is the interoperability case, in production.

Section 10 is a complete worked example — the reading and writing opcodes in
full, with hex, emitted by a conforming implementation and verified through a
script interpreter. Every figure in the document was checked against the
deployed scripts rather than derived.
The figures described a car that is no longer the one being raced. Both now read
off the public car minted 2026-08-16,
e918fa438f2cab12127fbd9377022868ad35904da2146816e552b26482b11c6a — 1,744 B, the
size its own runbook records for the car actually being raced.

The shell's lock has grown as rules were added: deployed cars measure 1,636 B,
1,674 B and 1,744 B across 15-16 August, and MAX_FEE is baked into the lock, so
a car is self-contained and races under the constants it was born with. The
quoted 1,672 B matches no deployed car - the nearest is 1,674 B. The quoted
opening bytes, with a zeroed driver field, do match three earlier deployments,
a genesis car being an empty shell, so that line described a superseded car
rather than an invented one.

The self-describing invariant was re-walked across all three deployed sizes and
holds in every case, which is the claim the section actually makes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sun-dive
sun-dive force-pushed the add-covenant-state-layout branch from 5272248 to 36a3673 Compare August 17, 2026 09:54
@sirdeggen
sirdeggen merged commit df88d58 into bsv-blockchain:master Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants