--- description: "The boilerplate every skill assumes: transaction flags, the entity-ID rule, the per-player charge bar, and proof-of-work policy. Read this once." --- # Structs Skill Conventions **The single source for the boilerplate every skill depends on.** Skills point here instead of repeating these rules. Read this once; the gameplay skills assume you know it. This is not a gameplay skill — it has no `SKILL.md` and is not invoked directly. It is the shared reference the other skills link to. --- ## Transaction flags (TX_FLAGS) Every `structsd tx structs` command needs gas flags. Two named bundles are used throughout the skills: - **`TX_FLAGS`** (interactive — the default): `--from [key-name] --gas auto --gas-adjustment 1.5` The CLI prints the transaction and prompts you to confirm before signing. This is the safe default for everything. - **`TX_FLAGS_APPROVED`** (only after commander approval): `TX_FLAGS` **plus `-y`**. The `-y` suppresses the confirmation prompt and signs immediately. `--gas auto` is mandatory. Without it, transactions fail with an out-of-gas error. ### The `-y` rule `-y` is **off by default**. Add it only after your commander has approved the action (see [SAFETY.md](https://structs.ai/SAFETY)). The one documented exception is **compute commands** (`struct-build-compute`, `struct-ore-mine-compute`, `struct-ore-refine-compute`, `planet-raid-compute`): they run for minutes to days and auto-submit their completion transaction when no shell is attached, so they ship with `-y` paired with an **Approval Block** that surfaces consent up front. For those, the Approval Block — not the CLI prompt — is your gate. --- ## Choosing your interface (capability-aware) Skills describe **what** to do; your environment decides **how**. Run `scripts/preflight.sh` once per session to detect what's available (it writes `config/environment.json`). Then: | Task | Best if available | Complete fallback | |------|-------------------|-------------------| | Read state / execute an action / hash | **Structs Desktop MCP** (`structs_action`, `structs_intel`, `structs_hash`) | `structsd` CLI (`tx`/`query`) | | Real-time threat/event response | **GRASS** / `structs_events` | poll with `structsd query` | | Galaxy-scale / low-latency intel | **Guild Stack** (PostgreSQL) | `structsd query` + [intel skill](/skills/structs-intel/SKILL.html) | | Build a tool / integrate | webapp/chain **API** | — | Rules of thumb: prefer **MCP** when it's connected (it adds preflight checks, GPU hashing, and a signing bridge that never exposes keys); otherwise use the **CLI** — every skill keeps a full CLI path. MCP `structs_policy`/`structs_doctrine` map to your operator autonomy in `config/operator.md`; they never widen autonomy beyond it. The CLI commands shown throughout the skills are always the ground-truth fallback. --- ## The `--` entity-ID rule Entity IDs contain dashes (`3-1`, `4-5`, `2-117`). The CLI parser treats a leading dash as a flag prefix, so unprotected IDs cause parse errors. **Always place `--` after all flags and before positional ID arguments:** ``` structsd tx structs struct-activate TX_FLAGS -- 6-10 ``` --- ## Proof-of-work `-D` policy Build, mine, refine, and raid all require proof-of-work. Difficulty decays with age, so the cheapest path is to **initiate early and compute later**. The `-D` flag (1-64) is meant to tell the compute helper to wait until difficulty drops to that level before hashing. > **Known issue in the structsd v0.23.0 CLI: `-D` does not wait.** The gate in every `*-compute` command reads `if target > currentDifficulty { sleep }` (`x/structs/client/cli/tx_struct_mine_compute.go:134-137`; the same in build, refine and raid). Difficulty starts at 64 and falls, so the condition is false until difficulty is already *below* your target: the CLI starts hashing at launch, keeps one core busy, and submits as soon as it finds a proof at the current difficulty — usually well before the D=3 age quoted in these docs. The chain math and the D=3 timings are correct; the "zero CPU wasted" claim is not, for the CLI. Until it is fixed upstream, to really wait: start the compute process later (for example `sleep` until the struct is old enough), or use a client that gates correctly (Structs Desktop and the webapp worker do their own waiting). Order still holds in the mine and refine pair: both hash at the same rate, and the refine's range (28,000) is twice the mine's (14,000), so the mine lands first. A refine that lands before any ore is stored is rejected, not wasted silently. - **`-D 3` is the canonical default for every operation.** At D=3 the hash is trivially instant; with a client that gates correctly, the wait is just the age clock, not grinding. Use this unless you have a specific reason not to. - **`-D 1`** is the only documented override: it targets an even lower difficulty, and the wait is much longer, not slightly — the age to reach D=1 equals the full range: ~23.3 h for a mine and ~46.7 h for a refine at 6 s blocks (vs ~17.2 h and ~33.7 h at D=3). Do not scatter other `-D` values through your work. - Higher `-D` values (8+) start sooner but burn exponentially more compute. The cliff between D=8 and D=9 is the single most important PoW fact — never set `-D` above 8. Full decay tables: [knowledge/mechanics/building](https://structs.ai/knowledge/mechanics/building). **Never block on PoW** — launch compute in a background terminal and track it in `memory/jobs/` (see [awareness/async-operations](https://structs.ai/awareness/async-operations)). --- ## Charge is per-player, not per-struct Charge is a **single shared bar per player**, not a value each struct carries: ``` charge = CurrentBlockHeight - player.lastActionBlock ``` Every charge-consuming action by **any** of your structs (build, activate, attack, move, defense change, stealth) requires charge on this one bar and resets it to 0 (charge is not a pool you spend down: it is simply blocks since your last charge action). It regenerates at 1 per block (~6 sec/block) whenever you are idle. To know whether an action can fire, query the **player**, not the struct. Action costs: activate 2, build-initiate 1, trash 1, defense-change 1, Command Ship move 3, primary weapon 3-5, secondary weapon 3-5, stealth activate 2. Deactivate (single or batch) costs 0 and works even while offline. Full table: [knowledge/mechanics/building#charge-accumulation](https://structs.ai/knowledge/mechanics/building). The practical constraint is **chaining**: each action resets the bar, so a burst of actions (activating several structs, repeated attacks) must be spaced by the next action's cost. The ante additionally refuses a second charge-consuming message from the same player in one block, and two charge messages in one transaction, so even 1-charge actions (build-initiate, trash) go one per block. --- ## Your Alpha lives in your vault Every player (`1-N`) and guild (`0-N`) has a **vault**: a protocol-controlled bank account derived from the owner ID (`structsd query structs vault [owner-id]` → `address`; balances via `structsd query bank balances [address]`). It is not a keyring key and is never a signing address. The rule of thumb: **game income lands in the vault, game spends are paid from the vault, and your signing key pays only native fees.** - Refined Alpha is deposited in the vault; `playerInventory.rocks` on the player query is the vault's spendable ualpha. - `reactor-infuse` / `reactor-defuse` / `reactor-cancel-defusion` / `reactor-begin-migration` act on the vault unless `--delegator-address` names a registered key (or `--owner-id` names a guild vault you control). - `struct-generator-infuse`, `guild-create` (2,000,000 ualpha) and guild rank purchases spend from the vault with no fallback to the key. - Move funds with `vault-send [owner-id] [recipient-owner-id] [amount]` (vault→vault), `player-send -- [from-address] [to-address] [amount]` (vault→key or key→vault), or a plain `bank send` to the vault address (key→vault, paid gas). Canonical explainer: [knowledge/mechanics/energy#vaults](https://structs.ai/knowledge/mechanics/energy). Skills say "from the vault" and assume this section. --- ## Query pagination Every paginated `structsd query structs` endpoint defaults to 100 rows and silently clamps `--limit` to 1000; `--count-total` is silently forced off, so `pagination.total` is always `0`; an `--offset` above 1000 is refused (`pagination offset exceeds maximum; use pagination key`). Walk large collections with `--page-key` from the previous response's `next_key`; do not size loops from `total`. --- ## One transaction at a time per account The chain tracks a sequence number per account. Submitting two transactions from the **same** account before the first is included causes `account sequence mismatch`. Wait ~6 seconds (one block) between transactions from one key. Different accounts can transact in parallel — this is the basis of multi-agent and delegation play (see [`structs-permissions`](/skills/structs-permissions/SKILL.html)). --- ## Scripting `structsd tx` (avoiding silent hangs) When you wrap `structsd` in a shell script (batch migrations, loops, background jobs), three things make a run look "stuck" or "do nothing." All three have bitten real runs: - **Do not capture stderr on a `tx`.** `structsd tx` writes the `Enter keyring passphrase:` prompt to **stderr** and reads the passphrase from stdin. Capturing output with `out=$(structsd tx ... 2>&1)` swallows the prompt, so the command blocks forever on invisible input. Instead, let stderr reach the terminal and capture only stdout (`structsd tx ... >"$tmp"`), or feed the passphrase non-interactively: `printf '%s\n' "$PASS" | structsd tx ...`. For a **batch of many txs**, a `file`/`os` keyring prompts **once per tx** — use `--keyring-backend test` (testnet) or pipe the passphrase, or you will be typing it hundreds of times. - **Guard command substitution under `set -e`.** With `set -euo pipefail`, `st=$(structsd status ...)` that exits non-zero aborts the whole script **silently** (no error printed). Wrap it: `if st=$(structsd status --node "$NODE" -o json 2>&1); then rc=0; else rc=$?; fi`, merge stderr, and tolerantly extract the JSON (e.g. regex the first `{...}`) since `status` output varies across builds. - **Never broadcast against a catching-up node.** If `structsd status` reports `sync_info.catching_up=true`, a `--broadcast-mode sync` tx is accepted but **never commits** — the classic "it hangs after broadcast." Check `catching_up=false` before broadcasting, and time out the commit-poll so a lagging node surfaces an error instead of spinning. See [api/integration-notes.md](https://structs.ai/api/integration-notes) for the data-shape counterparts (including why a permission error always says "administrate"). --- ## Skill authoring template Every gameplay skill follows this shape so agents can navigate any skill the same way: ``` --- name: structs- description: + explicit "Use when ..." triggers. level: beginner | core | advanced domain: --- # Title **What this is** (3-5 plain sentences a human can read). ## When to use it Signals/triggers that make this skill apply (wire to awareness/game-loop). ## Decisions Beginner default(s) + advanced considerations. "Decisions live in" → playbook link(s). ## Procedure Numbered steps. TX_FLAGS / -- / -D / charge are assumed from conventions.md (one-line pointer, not repeated). ## Commands reference Table of the CLI commands used. ## Verification How to confirm the action actually took effect (broadcast ≠ success). ## Errors Common failures and fixes. ## See also At least one playbook link and one awareness link. ``` **Frontmatter tags**: `level` (beginner / core / advanced) drives read-order in the generated index; `domain` groups related skills. Keep core skills ≤ ~250 lines (streaming and guild-stack are exempt). Never copy boilerplate that lives here — link to it. --- ## See also - [SAFETY.md](https://structs.ai/SAFETY) — the trust contract, operation tiers, Approval Block pattern - [AGENTS.md](https://structs.ai/AGENTS) — Critical Rules (the source of these conventions) - [awareness/game-loop](https://structs.ai/awareness/game-loop) — when each skill applies - [knowledge/mechanics/building](https://structs.ai/knowledge/mechanics/building) — PoW and charge ground truth