# Daedalus — the contract template catalogue Date: 2026-08-30, with an audit's corrections dated 2026-09-06 and a standards pass dated 2026-09-17 Status: **specification, then implementation.** This document was written before any template existed and says so throughout; **nineteen** are now shipped in `templates/` (counted 2026-10-29; this read *sixteen* until then, before `vesting-token` and `wrapped-token` on 2026-10-24 and `exchange-vault` on 2026-10-28 — §4.11), and everything the implementation proved wrong is recorded in the errata at the end rather than quietly edited. Read §4 as the design argument and the errata as the current state — where they disagree, the errata is right. *Corrected 2026-10-29: the next paragraph is closed.* Since 2026-10-07 `TEMPLATES` in `tests/helpers/templates.ts` lists every file in `templates/`, all nineteen, so the catalogue-wide properties reach each one, and the nine named in §4.10 are attacked individually by `template-tokens`, `template-payouts`, `template-nft-and-badge` and `template-multi-and-vault.integration.test.ts`. ~~**The nine templates added on 2026-09-17 are in a weaker evidence tier than the first seven, and §4.10 says so plainly.**~~ The first seven each have a dedicated adversarial suite. The nine compile, and each was deployed, called and validated on a real `BlockchainCore` by a script run once and not committed. Neither the catalogue-wide properties nor CI reaches them, because the set `template-catalogue.integration.test.ts` iterates is `TEMPLATES` in `tests/helpers/templates.ts`, and `tests/` was not the standards pass's to write. House name: **Daedalus** — Greek, the master craftsman whose designs other people built from. ~~A registry entry in [`NAMING.md`](NAMING.md) is owed.~~ **Written: `docs/NAMING.md:77` carries it**, and its entry states the warning the name is for — a template is copied without being read closely, so each ships with the adversarial test that proves its guard is load-bearing. --- ## 1. What was verified, and when This catalogue was written against the tree on 2026-08-30, **after** the runtime owner landed the v2 bytecode container. That matters because the honest answer to "writable today" moved substantially while this document was being drafted, and it may move again. Verified present in `runtime/`: | Landed | Detail | |---|---| | Maps | `MLOAD` / `MSTORE`, `map` keyword, declaration and index syntax in the compiler | | Loops | `while` and `for`, with a 20-gas charge on every backward jump so non-termination is bounded by the meter | | Checked unsigned subtraction | `SUBU`, 3 gas — underflow reverts instead of storing a negative `uint` | | String primitives | `CONCAT`, `LEN` | | Host surface | `SELF`, `TIMESTAMP`, `HEIGHT`, `BALANCE`, `TRANSFER`, behind `AresHost`, implemented by **Nidavellir** in `src/core/contract-state.ts` | | A complete gas table | every v2 opcode priced, with the reasoning written down | **Gas, v2**, from `runtime/vm.ts`: | Opcode | Gas | | Opcode | Gas | |---|---:|---|---|---:| | `TRANSFER` | 2100 | | `LOAD` | 50 | | `BALANCE` | 400 | | `CONCAT` | 6 + 1 per 32 code units of result | | `MSTORE` | 220 | | `REQUIRE` | 5 | | `STORE` | 200 | | `SUBU` | 3 | | `EMIT` | 100 | | `LEN` / `SELF` / `TIMESTAMP` / `HEIGHT` | 2 | | `MLOAD` | 55 | | everything else | 1 | plus **20 gas on every backward jump**, which is one loop iteration's fixed overhead. Default gas limit is 1,000,000, so a call affords roughly **470 transfers**, **4,500 map writes**, or **45,000 empty loop iterations** before it reverts. Those three numbers decide most of the sizing advice below. --- ## 2. The blocker that gated half this catalogue, and is gone **This section described a blocker that no longer exists, in either of its two forms, and it is rewritten rather than deleted because both fixes are consensus rules a reader has to know.** It said: a contract cannot be funded with native STR, because `LedgerManager.validate` refuses any transfer whose recipient has no allocated STR.domain and a contract address is a hash with no key behind it. Two changes have happened since. 1. **A deployed contract became a legal recipient.** `LedgerManager.validate` asks `contracts.has(tx.to)` — membership of the deployed set, which is in the state root, never a pattern match on the address string. A plain transfer is now the *only* way to fund a contract, because a call record carries no value. 2. **A wallet with no STR.domain at all became a legal recipient.** The receive-side identity gate is gone; see `docs/book/LEDGER_AND_STATE.md` §2.2.1. So the table now reads: | Direction | Allowed | |---|---| | contract → wallet, with or without a domain | yes | | contract → another deployed contract | yes | | wallet → contract | yes | | either → a **Hnitbjorg** account (Echo vault, Feeless Pool) | **no** — `src/core/hnitbjorg.ts` | **Spending is unchanged and is where the sybil cost is charged:** the *sender* of a transfer must hold a proved STR.domain, on every path, always. A contract can therefore **hold native STR and spend it**, in both directions. Inbound is a plain transfer from an ordinary wallet and is the only way, because a call record carries no value; outbound is `TRANSFER`, posted through Nidavellir's value journal all-or-nothing. **Measured rather than argued, twice.** The audit of 2026-09-06 settled 5 STR into a live contract over the public JSON-RPC and read the balance back — `contract STR balance = 50000000000000 minor`, [`reality/ARESLANG.md`](reality/ARESLANG.md) §9.1. And `npm run a1` now does both legs on every run against an in-process chain: a wallet funds a contract it just deployed with 5 STR, the contract pays 2 STR out to a second wallet under its own owner guard, and the remainder is asserted — three of that script's 42 checks. **What this section used to say here, kept because deleting it would hide how long it stood.** It read: *"A contract can therefore spend native STR it does not have and cannot get. Every template below that holds native value is blocked on this and on nothing else"*, and it then proposed extending `LedgerManager.validate` to admit a recipient in the deployed set. **That proposal is the code**, and was before this paragraph was last read: `src/core/ledger-manager.ts:472-484` asks `contracts.has(tx.to)` — membership of the deployed set, which is in the state root, never a pattern match on the address — under the comment *"A deployed contract is a recipient too, and this remains the ONLY way to fund one."* The two halves of this section contradicted each other for twenty lines, and a reader who stopped at the paragraph instead of the table concluded that escrow, vesting, multisig and the DAO treasury cannot hold native STR. They can, they do, and all four ship with adversarial tests that move it. **What is still blocked is a different thing, and the old proposal was mis-scoped for it:** a contract cannot learn **who** paid it. There is no deposit hook and a call record carries no value, so pooled custody governed by roles works and per-payer credit does not. Named precisely in "The gaps that remain" below, item 1. **A contract address cannot be funded before it is deployed**, either — the receive gate answers from the deployed set, so the only pre-funding path is a genesis allocation. **Every "blocked by §2" pointer in §4 below is dated 2026-08-30 and is read through the errata.** §4.3 vesting, §4.4 escrow, §4.5 multisig custody and §4.7 DAO treasury are shipped and adversarially tested holding **native STR**. §4.6 native staking and §4.8 a native-STR token sale are still not writable, for deposit attribution and not for funding. --- ## 3. Status legend | Mark | Meaning | |---|---| | **Today** | Writable against `runtime/` as verified on 2026-08-30 | | **Today, token-internal** | Writable today *if* the asset it moves is a ZK13 token whose ledger is in the same contract. **The reason given for this mark was §2's funding blocker, which is gone**; four of the entries carrying it are shipped holding native STR (§2). Where the mark still stands, it stands on deposit attribution — the pattern has to credit an identified payer, and no contract can learn who paid it | | **In flight** | Depends on work in progress, or on a decision not yet made | | **Proposal** | Nothing exists; this document argues for it | Where a boundary is genuinely uncertain, the entry says **in flight** rather than guessing. An aspirational catalogue is worse than a short one, because the next wave implements from it. --- ## 4. The templates ### 4.1 Fungible token (ZK13) — **Today** **Purpose.** The base asset: balances, transfer, mint, burn, ownership, pause. Everything else in this catalogue is built beside it or on top of it. **Surface it needs.** `map` for balances (`MSTORE` 220, `MLOAD` 55), `SUBU` for the debit, `caller`, `require`, `emit`. No host opcodes at all. No loops. **Cost, counted** on the v2 table for the hot path — `transfer` on an existing holder: two `MLOAD` (110), one `SUBU` (3), one `MSTORE` for the sender and one for the recipient (440), one `EMIT` (100), the guards (roughly 20), plus locals. **Roughly 700 gas.** Declare a gas limit of at least 7,000 so the post-mining ceiling covers it — see [`ARESLANG_STDLIB.md`](ARESLANG_STDLIB.md) §3.1, `minted = min(gasUsed, gasLimit / 10)`. **Security properties it enforces.** Supply moves only through mint and burn; a revert leaves the ledger untouched, by construction rather than by unwinding; the code cannot be changed after deployment; the caller is authenticated by signature when the ledger runs in `signed` mode. **How it is typically misused.** - **Assuming a holder is a person.** Receiving is not gated by STR.domain and cannot be — [`ZK13_TOKEN_STANDARD.md`](ZK13_TOKEN_STANDARD.md) §3. A template that computes airdrop eligibility or voting weight from `balanceOf` computes it over an unauthenticated set. - **Self-transfer inflation.** `bal[from] - amount` then `bal[to] + amount` with `from == to` overwrites the debit and mints from nothing. The standard mandates `require(to != caller, "self transfer")`. - **Sending to a contract address.** No contract can spend a ZK13 balance held at its own address unless it is the token contract itself, because there are no cross-contract calls. Permanent loss. - **Under-declaring the gas limit**, so the network absorbs the shortfall silently on every transfer forever. **Generated rather than edited.** `strblk contract new-token` and the explorer form at `/contracts/templates/zk13-token/configure` compose this template into a finished token from an issuer's answers. Since 2026-10-26 they offer every option this VM can build: votes and delegation, snapshots, and the `+vesting` and `+wrapped` profiles as conforming options; renounce, burnFrom, a blocklist, allowances, a fee on transfer and anti-whale limits as extensions OUTSIDE the standard, each generated only on request and labelled not ZK13-conforming in the contract name, `standard()`, the source header, the manifest, the form and the explorer's page for the deployed contract. Permit, flash mint, transfer hooks, upgradeable proxies and managed access are shown disabled with the missing instruction. The list, verdict by verdict, is [`ZK13_TOKEN_STANDARD.md`](ZK13_TOKEN_STANDARD.md) §14; the extensions are §14.2, and they do not amend the standard. ### 4.2 Domain-bound NFT — **split: the NFT is Today, the binding is In flight** **Purpose.** A non-fungible token whose ownership is tied to an STR.domain rather than to a bare address. **Be clear what this is not.** The native `WNFT` is one per STR.domain, minted by the domain registry, backed by 1000 STR locked, and **non-transferable** — `TOKEN_DEFINITIONS` marks it so because *"a domain WNFT is bound to its holder; transferring it would transfer an identity."* A contract NFT is a different object with a similar name. A template that lets a user believe they are minting a domain WNFT is the most dangerous mislabelling in this catalogue, and the template must not use the name. **Surface.** A plain NFT — `map` from token id to owner, mint, transfer, an `Owner` event — is **Today**. The *domain binding* is **in flight**: `AresHost` exposes `selfAddress`, `blockTimestampMs`, `blockHeight`, `balanceOf` and `transfer`, and **no domain accessor**. A contract cannot ask whether an address holds a proved domain, or which domain it holds. **Proposal.** `isProvedDomain(address) -> bool` and `domainOf(address) -> string` on `AresHost` — argued in [`ZK13_TOKEN_STANDARD.md`](ZK13_TOKEN_STANDARD.md) §3.6. It is deterministic: `produceBlock` settles allocations and registrations before contract records, in one order every node uses. **Misuse.** Storing a domain string in the NFT and treating it as proof of anything. A string is a string; without the host accessor the contract has verified nothing, and case folding (`STR.TREASURY` beside `STR.treasury`) is an impersonation primitive the contract cannot even detect — `normalizeStrDomain` is not reachable from AresLang. **Where the plain NFT went, 2026-09-17.** It now has a standard — [`ZK13_NFT_STANDARD.md`](ZK13_NFT_STANDARD.md) — and two implementations: `zk13-nft.ares` with per-token metadata and O(1) holder enumeration, and `nft-collection.ares`, the minimal one, which that standard records as **non-conforming** (it lacks `standard()`, `tokenUri()`, `totalSupply()` and `exists()`) rather than editing a shipped file whose bytecode is in every address derived from it. **The binding half of this section is still In flight and nothing above it has changed.** ### 4.3 Vesting — **Today, token-internal** **Purpose.** Release an amount to a beneficiary over time, with a cliff. **Surface.** `TIMESTAMP` (2 gas) for the clock, `map` for schedules, `SUBU` for the released arithmetic. All present. **The rule that makes it safe, and it is not optional.** *The contract reads the block's time; it never takes a time as an argument.* `AresHost.blockTimestampMs` is documented as "the sealed header's timestamp, never `Date.now()`", so every node replaying the block computes the same release. A caller-supplied timestamp is a caller-supplied unlock date, which is the whole of the vulnerability. **Native STR vesting is blocked by §2** — the contract cannot be funded. Vesting a ZK13 token whose ledger is the same contract needs no transfer at all: the locked amount is a slot, and release is a book entry. **Misuse.** - Computing the released amount as `total * elapsed / duration` and paying `released` rather than `released - alreadyPaid`. Pays the whole schedule on every call. - A revocable schedule with no notice. If the issuer can revoke, the beneficiary must be able to read that from the ABI before accepting the grant, for the same reason §6.5 of the token standard requires a declared allowlist. - Using `HEIGHT` and `TIMESTAMP` interchangeably. Prefer height for anything adversarial: a producer has some latitude over the timestamp it writes and none over the height. ### 4.4 Escrow — **Today, token-internal** **Purpose.** Hold an asset until a condition is met, release to one party or refund the other, with a timeout. **Surface.** `TIMESTAMP`, `map`, `caller`. **Today** for a ZK13 token held in the same contract. For native STR: outbound `TRANSFER` works and inbound funding does not (§2). **Security properties.** Two-party release with a deadline is the one pattern in this catalogue where the atomic-revert property is load-bearing: a release that fails halfway is not a state this VM can reach, because Sindri commits only on success and Nidavellir's value journal posts all-or-nothing — *"either `move` is never called, or every `move` is called and each one is known to be fundable."* **Misuse.** - **No timeout.** An escrow whose release depends on a party that disappears is funds locked forever in an immutable contract. Every escrow must have a deadline after which one side can unilaterally recover. - **An arbiter with no declared limit.** If a third party can decide, that is a custody relationship and must be visible in the ABI, not in a README. - **Assuming reentrancy protection is needed.** There is no contract-to-contract call opcode, so a transfer cannot re-enter — the code says so explicitly, and adds that *"if one is ever added, the reentrancy question has to be answered here before the opcode ships."* Write checks-effects-interactions anyway; ordering is free and a guard is 460 gas. ### 4.5 Multisig — **split: gating its own state is Today, gating value is Today for payouts and blocked for custody** **Purpose.** Require M of N approvals before an action. **Surface.** `map` for the owner set and for per-proposal confirmations, `while`/`for` to count, `caller`. All present. **What it can actually do, stated precisely.** There are no cross-contract calls, so a multisig **cannot execute an arbitrary call on another contract**. Its authority is limited to: - changing state inside its own contract — **Today**; - paying out native STR with `TRANSFER` — **Today**, but only from a balance it cannot be given (§2); - moving a ZK13 token whose ledger is the same contract — **Today**. A general-purpose "multisig wallet that can call anything" is **in flight** and depends on a call opcode that does not exist and whose reentrancy question is explicitly unanswered. **Misuse.** - **Counting confirmations in a loop over an unbounded set.** At 20 gas per backward jump plus 55 per `MLOAD`, a few thousand owners is a contract that becomes uncallable — permanently, because the code is immutable and the funds are behind the frozen function. Bound N at deployment and refuse to exceed it. - **A threshold that can be lowered by the threshold.** If M-of-N can change M, then M-of-N is really 1-of-N over time. Changing the threshold should require the higher of the current and proposed threshold. - **Confirmations that survive a proposal being edited.** A confirmation must bind the exact action, or approving one thing and executing another is a signature-reuse bug in slow motion. ### 4.6 Staking — **Today, token-internal** **Purpose.** Lock a token for a period and accrue a reward. **Surface.** `map`, `TIMESTAMP`, `SUBU`, arithmetic. All present. **The arithmetic warning that is specific to this VM.** AresLang integers are arbitrary precision with a **4096-bit ceiling**, so a reward computed as `rate * elapsed * amount` does not wrap — it either produces a correct enormous number or reverts at the ceiling. Neither is a silent corruption, which is better than most chains; but a reward accrual whose product grows without bound will eventually revert and strand the position. Normalise before multiplying, and cap the accrual window. **Do not confuse this with validator staking.** Validation power is declared in the genesis and is not chain state — `validatorSetCommittedAt` returns a constant, and the code says so: *"validator admission is not chain state yet."* A staking contract confers no consensus weight of any kind, and a template implying otherwise is claiming something the chain does not implement. **Misuse.** - Paying rewards from a pool that can be drained by the last unstaker, with no accounting for who is owed what. The shipped template keeps that accounting in `rewardOwed`: a settlement that cannot pay in full carries the remainder rather than destroying it. What it cannot do is promise the pool will ever hold it. - Accruing on a timestamp the staker supplies. - Allowing unstake to compute rewards from a `lastUpdate` the same call already overwrote. - **Gating `unstake` on the pause.** A pause that holds the principal is a pause that takes it: one bool, set by one key, with no renounce and no second key that could end it. Hold the reward pool if you must hold something; never the stake. See the errata below — this one was executed. ### 4.7 DAO treasury — **In flight** **Purpose.** Collective control over a pot of value. **Why in flight rather than Today.** It needs all of: custody of native value (§2, blocked), proposal state (Today), voting (Today), and execution of an arbitrary action (no call opcode). Three of four is not a template. **What it must never claim, and this is the important part.** A DAO treasury governs **its own contract storage and nothing else**. Chain-wide parameters belong to the Althing, at a strict majority of its electorate, and there are exactly **ten** governance action kinds in `Odin`: `set-parameter` over an enumerated bounded registry, `admit-member`, `remove-member`, `burn-pool`, `halt-chain`, `rotate-attestors`, `schedule-rules`, `admit-validator`, `evict-validator` and `rekey-validator`. **None of them mints a token, credits an account or writes arbitrary state**, deliberately, because *"a governance system that can change anything is a governance system that can be used to steal."* A DAO template that presents itself as SourceLess governance is presenting authority it does not have. **Misuse.** Live-membership tallying. Odin freezes the electorate at proposal time for a stated reason: *"admitting a large member mid-vote defeats a proposal that had already passed, and removing members shrinks the threshold until an existing minority's votes clear it."* A DAO template that tallies against current membership has both bugs. Copy the frozen-roll rule. **And the misuse the frozen roll does not cover, which an audit executed:** an administrator who can change the roll is a majority of every future roll, whatever the tallying rule. A steward that can admit can admit addresses it controls, and no contract on this chain can tell those from independent members. The shipped template therefore makes the two powers exclusive in time — nothing can be proposed while the roll can still be changed by one key — rather than bounding one of them. Anything less is a treasury with a declared co-owner, and it should say so in those words. ### 4.8 Token sale / distribution — **Today, token-internal** **Purpose.** Exchange one asset for another at a declared rate, within a window. **Surface.** `TIMESTAMP`, `map`, arithmetic — present. Taking payment in native STR needs §2. **Misuse.** A rate the owner can change mid-sale; no cap, so the sale can mint past the token's own `maxSupply` and revert unpredictably once it hits it; no refund path if the sale fails to reach a minimum, in a contract that cannot be upgraded to add one. ### 4.9 Allowlist / registry — **Today** **Purpose.** A mapping from address to a status flag, readable by anyone, writable by an owner. The simplest useful template and the one most likely to be needed early — it is the mechanism behind the domain-gated token in [`ZK13_TOKEN_STANDARD.md`](ZK13_TOKEN_STANDARD.md) §3.5. **Cost.** One `MSTORE` (220) per entry, one `MLOAD` (55) per check. **Misuse.** Batch-adding in an unbounded loop; at 220 gas per write plus 20 per iteration, the default limit affords roughly 4,000 entries in one call and a batch sized by an argument will revert at some size the caller discovers by hitting it. Bound the batch in the contract. **Shipped 2026-09-17 as `templates/allowlist-token.ares`** — the allowlist is not a standalone registry but the gate on a token's transfers, which is the form §3.5 of the token standard asked for. It adds one address at a time (775 gas on a real change, 190 when the flag is already what was asked for) and has no batch, for the reason above and because there is no array type to batch with. ### 4.10 The standards pass — **shipped 2026-09-17, nine templates, weaker evidence tier** Written with the three sibling asset standards ([NFT](ZK13_NFT_STANDARD.md), [multi-token](ZK13_MULTI_TOKEN_STANDARD.md), [vault](ZK13_VAULT_STANDARD.md)) as their reference implementations, plus four contracts the catalogue was missing and one that realises §4.9. | Template | What it is | The one thing to read first | |---|---|---| | `zk13-nft.ares` | the NFT standard's reference: per-token metadata fixed at mint, O(1) holder enumeration by swap-and-pop | Metadata is written once and no function changes it. An immutable pointer to mutable content is still mutable content | | `zk13-multi-token.ares` | the multi-token standard's reference: many ids, per-id cap, per-id metadata, one owner and **one global pause** | The pause is global. Assets that need independent stops need independent contracts | | `zk13-vault.ares` | the vault standard's reference: asset ledger and share ledger in one contract, rounding always against the caller, virtual-offset pricing | `redeem` and `withdraw` are NOT pausable, and the pool can never be fully emptied | | `fixed-supply-token.ares` | one `issue()` call, then no owner, no pause and no minter anywhere in the ABI | No emergency stop, ever. And a deployer key lost before `issue()` leaves the token permanently unissuable | | `allowlist-token.ares` | §4.9 and §3.5 realised: both sides of every transfer checked against a list one named key writes | Removal is a selective freeze, which the token standard permits **only** when declared. It is declared | | `soulbound-badge.ares` | non-transferable credentials: kinds, expiry, holder renunciation, optional revocation fixed at deployment | Non-transferability is enforced by the absence of a transfer function, which is the only enforcement available here | | `payment-splitter.ares` | native STR in, fixed shares out, **pull** payments | Push would need a transfer in a loop whose length the roll controls, which becomes uncallable at a size nobody chose | | `timelock.ares` | queued native payouts with a delay nobody can shorten, a grace window, and execution open to anyone after the wait | It cannot timelock a CALL, because there are no cross-contract calls. Only a payment out of its own balance | | `faucet.ares` | a fixed drip with a per-address cooldown and a lifetime cap, plus a declared owner sweep | The per-address limit is only meaningful because a call requires a proved STR.domain. The gate does that work, not this contract | **Surface all nine needed, and none of it was new:** `map`, `SUBU`, `require`, `emit`, `caller`, `self`, `timestamp`, `balance`, `transfer`. No compiler or VM change was asked for or made. What they cost is in [`../templates/README.md`](../templates/README.md), measured per entry point. ~~**What they are missing:** a committed test each.~~ *Closed 2026-10-07; see the status block at the top of this document.* A standard's own "what is not built" section may still record the old debt. ### 4.11 Added after the standards pass — **three templates, each with its own suite** §4.6's shipped template is `staking-token.ares`. These three came later and had no entry here until 2026-10-29. | Template | Added | What it is | The one thing to read first | Suite | |---|---|---|---|---| | `vesting-token.ares` | 2026-10-24 | the `+vesting` profile of the ZK13 token standard: a fungible token whose mint authority can grant a beneficiary a total that vests linearly over a window fixed at grant | A grant spends cap room the moment it is made and mints nothing until `release`. It enforces the release rate, not the backing, and a grant cannot be clawed back | `template-vesting-token.integration.test.ts` | | `wrapped-token.ares` | 2026-10-24 | the `+wrapped` profile: a 1:1 bridge-custodied wrapper whose custodian is the mint authority; `unwrap(amount, ref)` burns and announces where the underlying should go | The contract cannot see the other chain and cannot validate `ref`. A wrapped balance is a claim on the custodian, no stronger than the custodian | `template-wrapped-token.integration.test.ts` | | `exchange-vault.ares` | 2026-10-28 | one exchange's STR liquidity at a public address, payable only to an active deposit address or back to the return address fixed at deployment | Every power over where the money goes is queued in public and executes only after a delay; the contract cannot see who paid it or check that a deposit address belongs to the exchange | `template-exchange-vault.integration.test.ts`, `exchange-vault-custody.integration.test.ts` | --- ## 5. Rules every template obeys 1. **Two-step ownership handover.** There is no administrator anywhere in SourceLess who can reach into a contract's slots; a one-step handover to a mistyped address is permanent. 2. **Reads are never paused.** A stuck contract must stay auditable. 3. **No unbounded iteration over caller-controlled data.** The code is immutable, so a function that becomes too expensive is a function that is gone. 4. **The clock is the block's, never an argument.** 5. **Every state-changing function emits.** Events are not in the state root — Sindri excludes them deliberately — so they are evidence and never logic, but without them there is no audit trail at all. 6. **Declare a gas limit of at least ten times expected use**, or the network silently absorbs the shortfall on every call. 7. **State the powers the deployer keeps, in the ABI.** Pause, mint, freeze and revoke must be readable from `catalog(address)` before a user commits value, because a wallet reads an ABI and not a whitepaper. --- ## 6. What is not built Rows are struck as they close rather than deleted, so the contradiction between what this catalogue argued for and what the tree now does stays on the record. What is still unstruck is still missing. | Not built | Consequence | |---|---| | ~~Every template in this catalogue~~ **Built.** Seven `.ares` files in `templates/`, each with an adversarial test: `template-zk13-token` (20), `template-dao-treasury` (19), `template-staking` (18), `template-catalogue` (15), `template-escrow` (12), `template-multisig` (11), `template-nft` (11), `template-vesting` (9) — 115 tests, deployed on a real chain | This row said "this is a specification". The status line at the top of this document says otherwise and has since it was rewritten; the row was the half that was not updated | | ~~Funding a contract with native STR (§2)~~ **Built.** `LedgerManager.validate` admits a recipient in the deployed set — `contracts.has(tx.to)`, membership of state in the root (`src/core/ledger-manager.ts:443`) | This row contradicted §2 of this same document, whose heading is "The blocker that gated half this catalogue, and is gone", and the errata entry below that says §4.3 vesting, §4.4 escrow, §4.5 multisig custody and §4.7 DAO treasury are all shipped and adversarially tested holding **native STR** | | A cross-contract call opcode | Blocks a general multisig and a DAO that executes anything outside itself. Still true: `AresOp` has no `CALL` (`runtime/bytecode.ts`), and the gas table prices none | | A domain accessor on `AresHost` | Blocks the domain binding in §4.2 and the receive-side rule in the token standard. Still true: `isProvedDomain` / `domainOf` exist on no host interface, and [`ZK13_TOKEN_STANDARD.md`](ZK13_TOKEN_STANDARD.md) §8 still carries the row | | ~~Address well-formedness in `validateArgs`~~ **Built.** The `address` branch checksum-validates before the first opcode (`src/core/contract-state.ts:1642`), and `Nidavellir.transfer` re-checks at the moment value moves, because an address can also arrive from storage | This row said every template must guard `require(to != "")` itself. It need not; see the errata below and [`ARESLANG_STDLIB.md`](ARESLANG_STDLIB.md) §5.6 | | ~~A caller-side STR.domain gate on contract calls~~ **Built.** `contractCallerGate` (`src/core/blockchain.ts`) refuses any deploy or call whose actor is not proved, enforced on submit, produce and accept | This row said an address with no domain can deploy and call contracts today. It cannot; [`ZK13_TOKEN_STANDARD.md`](ZK13_TOKEN_STANDARD.md) §8 recorded the same closure and this table did not | | ~~A `NAMING.md` entry for **Daedalus**~~ **Written.** `docs/NAMING.md:77` | Owed to the naming owner, and paid | | An aggregate argument type (array or list) | Blocks every batch operation in the catalogue: a batch transfer, a batch mint, an airdrop in one call. Every AresLang parameter is one scalar, so n movements are n signed call records, atomic individually and never together. Still true as of `areslang-1.2.0` | | An integer-to-string builtin | Blocks `tokenUri` derived as `baseUri + id`, so `zk13-nft.ares` stores every token's whole URI in permanent state. The builtins are `len`, `concat`, `balance` and the statement `transfer`, and none of them renders a number | | A hashing opcode | Blocks a Merkle allowlist, a commit-reveal, and any check of the form "the issuer signed this". `allowlist-token.ares` therefore stores the list one address at a time | | A committed test for the nine templates added 2026-09-17 | They are not in `TEMPLATES` in `tests/helpers/templates.ts`, so neither their own suites nor the catalogue-wide properties exist for them. **Two handoffs**, and the reason the status block at the top calls their evidence a weaker tier | | A `NAMING.md` amendment for the asset standards family | `docs/NAMING.md:136` entry (3) names the *ZK13 token standard*; there are now four — fungible, NFT, multi-token, vault. Owed to the naming owner, who is the only desk that may edit that file | --- ## Errata — corrected by implementation Everything below was written before the code existed and proved wrong once it did. A specification nobody has implemented is a draft, and these are recorded rather than quietly edited so that anyone who read the earlier version can see what moved. ### Corrected in `ARESLANG_STDLIB.md` - **§7's recommendation — access control as a compiler feature (`fn withdraw() only(owner)`) — is withdrawn.** The document's own boundary rule defeats it: the compiler is code every node runs identically forever and cannot change without a fork, so a library routine placed there makes an access-control policy a **consensus rule**. The day someone wants a different message or a three-key owner, the fix would be a hard fork. §7 objected to a textual prelude on the grounds that "the deployed bytecode differs from the source the author wrote" — but that is about *where* the splice happens. Composition happens **before** compilation, in ordinary application code, and the composed text *is* the contract. - **§5.6's headline change has landed.** `isValidAddress` in `validateArgs` is in the tree; an `address` parameter needs no in-contract guard. The residual is text in a `string` slot. - **§5.2's "roles — needs maps, in flight" is stale.** Maps landed; roles ship as a full `map>`. - **§5.1 still lists `sub(a, b)` as a library routine.** It is refused: `SUBU` is 3 gas, cannot be omitted because `uint - uint` is checked by type, and a wrapper would cost more while teaching that the wrapper is what makes it safe. - **§3 and §0.1 carry two different gas tables**, and §3 is the v1 one — no `MLOAD`, `MSTORE`, `SUBU`, `BALANCE` or `TRANSFER`. `stdlib/gas.ts` is authoritative and is re-measured by the test suite, so a wrong number there fails CI. - **`&&` and `||` DID not short-circuit, and now do.** Writing that limitation down is what got it fixed — see compiler `areslang-1.2.0`. The library's measured cost for `onlyOwnerOrRole` fell from 119 gas to 60 on the owner path as a direct result. ### Corrected in `ZK13_TOKEN_STANDARD.md` - **§6.6's justification is factually wrong about this VM.** The two-statement debit-then-credit does **not** inflate when `from == to`: `MSTORE` writes through, so the credit reads the already-debited value. Measured both ways. The bug appears only when both balances are cached in locals first. **Keep the mandated guard** — it makes that future edit harmless — but the stated reason for it is not the reason. §6.6's hedge about "map semantics still in flight" is resolved: they are sequential. - **§5.4's `empty recipient` rule is unreachable on the record path**, since `validateArgs` checksum-validates every `address` argument before the first opcode. The guard is kept as defence for a future caller path, and is documented as such rather than as live protection. - **§5.3's "set `minter` to `''`" cannot be expressed**, because `""` fails the `address` ABI check. It needs a dedicated zero-argument `closeMinting()`, which is what the reference implementation does. The same applies to cancelling a pending owner. - **§4.3's event set has no event for `proposeOwner`**, which contradicts §6.4's own argument that a two-step handover "leaves a window in which the pending change is visible on chain" — visible in storage, invisible in the log. The reference adds `OwnerProposed`. ### Corrected by an audit that EXECUTED the exploits, 2026-09-06 Not review comments. Each of these was run against a deployed instance on a real chain, each one succeeded, and each one left a chain that still validated afterwards — which is the point: none of them is detectable as an invalid state, because none of them is one. Every entry is now closed in the template, and every entry has a test that performs the same sequence and asserts the revert. | Executed | What it took | What it is now | |---|---|---| | **The DAO treasury drained by its own steward** | four calls: remove all five members, admit itself, propose a payment to itself, vote once against a roll of one, execute | `admit` refuses the steward, `remove` and `renounceSteward` hold a floor of three, and — the load-bearing one — `propose` refuses to create anything at all while `stewardActive` is true. `execute` can only pay a proposal, so while one key can still change the roll, no value can leave by any path. The membership powers the steward loses at renunciation become `proposeAdmit` and `proposeRemove`, decided by the same strict majority as a payment. | | **The staking pause froze every staker's principal** | `setPaused(true)`; `unstake` required `frozen == false`, and there is no `renounceOwnership` anywhere | `unstake` is the one mutating function the pause does not gate. The REWARD is still held by a pause — that is the contract's money — and is carried as a debt rather than dropped. | | **The escrow arbiter named ITSELF the seller** | `open(buyer, arbiter, …)` then `release`, taking funds transferred in before `open`, which status 0 has no way to return | `open` refuses an arbiter that is either party. Status 0 still has no exit and cannot have one — there is nobody the contract could honestly pay — so the header now says in capitals to fund only after `open`. | | **A fixed cap outrun by mint → burn → mint** | 4,000 issued against a cap of 1,000, in four calls, no revert | the cap bounds `lifetimeIssued()`, which never goes down, and not `totalSupply`, which `burn` lowers. Both token templates. | | **A staker's earned reward destroyed by their own claim** | claim against a short pool paid the clamped amount and restarted the clock; the difference was gone, with a `RewardPaid` event for the smaller number | the shortfall is carried in `rewardOwed`, readable as `rewardOwedOf`, and paid out of the next refill. A refill is still first come, first served, and the header calls that a race rather than implying a queue. | | **The NFT collection had no emergency stop** while the other two asset templates had one | — | `setPaused` covers mint, transfer and burn, and no view. Its cost is that an owner who pauses and loses the key freezes the collection forever, which the header states. | Two decisions taken while fixing those, recorded because they are decisions and not oversights: - **Both token templates still ship `supplyCap = 0`, which is uncapped.** A template cannot invent a cap for a token it knows nothing about, and a plausible-looking placeholder reads as a decision somebody made. What changed instead is that the number is now checkable: `maxSupply()` bounds `lifetimeIssued()`, and both are in the ABI, so "fixed supply" is either a cap somebody set or a `closeMinting()` somebody called — never a claim in prose. - **The DAO treasury's roll can no longer be changed by one key at any point in its life, and that includes the price.** A roll that only its own majority can change cannot survive losing a majority of its keys at once: nothing passes, including the removals that would fix it. The alternative was a steward who could retire dead members, which is the drain above. The header states the trade rather than choosing quietly. ### Corrected in `CONTRACT_TEMPLATES.md` - **§2 is stale, and it gated half the document.** "A contract cannot be funded with native STR" is no longer true. Consequently §4.3 vesting, §4.4 escrow, §4.5 multisig custody and §4.7 "DAO treasury — in flight" are all writable today, and all four are shipped and adversarially tested. - **§2's own proposal was mis-scoped.** It claimed the funding clause "unblocks the most of this catalogue". It unblocked **custody**. It did not unblock the **deposit-attribution** class, which is what actually prevents native staking, a token sale, a per-user vault and a tip jar — see below. - **A contract address cannot be funded before it is deployed.** The receive gate answers from the deployed set, so the only pre-funding path is a genesis allocation. --- ## The gaps that remain, named precisely Recorded here because each one blocks a specific, obvious thing a user will try. 1. **Deposit attribution.** A call record carries no value and there is no deposit hook, so a contract cannot learn *who paid it*. Escrow, vesting, multisig and the treasury work because their funds are pooled and governed by roles. Native staking, a token sale, a per-user vault and a tip jar all need to credit a payer, and cannot. This is the single highest-value remaining item for templates. 2. **No domain accessor on the host.** `AresHost` exposes `selfAddress`, `blockTimestampMs`, `blockHeight`, `balanceOf` and `transfer`. A contract cannot ask whether an address holds a proved STR.domain, so a domain-bound NFT — a wNFT — is not writable. The shipped `nft-collection.ares` is an honest plain NFT, and a test asserts its source mentions no domain at all. 3. **No user-defined function calls.** The library is composed source rather than linked code, so any logic two entry points share is copied. There are two such triples in the catalogue — the staking accrual behind `ACCRUAL BEGIN/END`, and the DAO treasury's proposal block behind `PROPOSAL BEGIN/END` — and both are now held identical by a test that extracts all three copies from the shipped file and compares them character for character. A drifted copy is not something a reviewer finds by eye in a 400-line file, and the failure it causes is a payout on whichever path is more generous. 4. **Nothing links the stdlib to the templates.** `stdlib/` emits `owner` and `hephaestus/not-owner`; the templates emit `contractOwner` and the ZK13 standard's own revert strings, which wallets match on, so composing the templates from the library would change every documented message and every ABI in the catalogue. What exists instead is a pin: for every guard the library can express, `template-catalogue.integration.test.ts` compiles the statement the template ships and the statement the library emits and requires the same instruction stream. A guard hardened in `stdlib/` fails that test until the templates carry the hardening too. 5. **No cross-contract calls**, so a general multisig or DAO that acts on another contract is not writable. 6. **No constructor arguments.** Every parameter is a source constant the user edits or a post-deploy setter. `state owner: address = caller;` works because the initializer runs with the authenticated deployer as caller — so no template needs a `claimOwnership` call, and there is no claim race. 7. **Deployment gas is unmeasured.** `applyDeploy` returns no `gasUsed`, so `postMineForContractRecord` skips deploys. Left unmeasured rather than estimated. 8. **No aggregate argument type.** Every parameter and every return is one scalar, so there is no batch operation anywhere in the catalogue and cannot be one. A user who wants to pay 200 people sends 200 records. Added 2026-09-17 with the multi-token standard, which is where the absence costs the most. 9. **No integer-to-string conversion and no hashing opcode.** The first forces every NFT to store its whole metadata URI rather than deriving it from an id; the second rules out a Merkle allowlist, a commit-reveal and any "the issuer signed this" check, which is why `allowlist-token.ares` stores its list one 220-gas write at a time. 10. ~~**Nine of the sixteen templates have no committed test.**~~ *Closed 2026-10-07: each of the nine now has a suite, and `TEMPLATES` lists all nineteen. The rest of this item is the record.* `zk13-nft`, `zk13-multi-token`, `zk13-vault`, `fixed-supply-token`, `allowlist-token`, `soulbound-badge`, `payment-splitter`, `timelock` and `faucet` compile and were each deployed, called and validated on a real `BlockchainCore` once, by a script that was not committed because `tests/` and `scripts/` were not the standards pass's to write. **This is the largest debt the 2026-09-17 pass leaves**, and it is recorded in each standard as well as here.