Purpose: Hard-won, verified notes for anyone building against the live Structs chain and Guild API (bots, MCP servers, dashboards). These are the data-shape and endpoint details that cause silent integration bugs. Each note is tagged with where it was verified.
Scope: this page is about the game API / proto / data shapes. For the proof-of-work mechanism see hashing.md; for combat math see combat.md.
The public testnet exposes the standard Cosmos surfaces over TLS. There is no port 1317 on the public host — that port is local-devnet only.
| Surface | URL | Notes |
|---|---|---|
| REST (LCD) | https://public.testnet.structs.network |
Standard HTTPS, no port. http://...:1317 is dead (connection refused). |
| Tendermint RPC | https://public.testnet.structs.network:26657 |
Block, tx, status |
| gRPC | public.testnet.structs.network:9090 |
If exposed for your tooling |
| Local devnet LCD | http://localhost:1317 |
Only when you run your own node (see local-devnet.md) |
Caveat — a 501 is often a wrong URL, not an unimplemented query. The gRPC-gateway returns gRPC code 12 (“Not Implemented”) for routes that do not match a registered annotation. Verified on both local LCD (http://localhost:1317) and public testnet:
| Wrong (501) | Correct (200) |
|---|---|
/structs/params |
/structs/structs/params (the only route that keeps the doubled structs) |
/structs/structs/struct_type/{id} |
/structs/struct_type/{id} |
/structs/guild_rank_permission_by_object/{objectId} |
/structs/guild_rank_permission/object/{object_id} |
/structs/guild_rank_permission_by_object_and_guild/{objectId}/{guildId} |
/structs/guild_rank_permission/object/{object_id}/guild/{guild_id} |
/structs/player_halted |
(no such query — removed from the module) |
Authoritative path list: option (google.api.http).get annotations in .references/structsd/proto/structs/structs/query.proto. When an LCD route 501s, check that file before assuming the feature is missing. Fall back to the CLI (structsd query structs ...) or the Guild Stack PostgreSQL mirror if the annotation really is absent.
The query docs under api/queries/ use http://localhost:1317 as a generic base — substitute the live HTTPS base above for testnet.
The Guild API serializes numeric fields as JSON strings, not numbers. Naive numeric use (a + b, comparisons) silently misbehaves.
{ "health": "6", "last_action_block_height": "1337217", "ore": "5", "load": "25000", "capacity": "1000000" }
Always coerce: parseInt(x, 10) for counts/heights, and BigInt for precise energy/capacity values (the client divides load/capacity/structs_load by an energy precision factor). Verified in webapp src/js/factories/PlayerFactory.js (Number(BigInt(numberString) / BigInt(PRECISION))) and src/js/api/GuildAPI.js (parseInt(...) on block heights and counts).
Blanket rule: treat every Guild API numeric as a string at the wire and convert explicitly.
Note this also applies to chain LCD responses: protobuf JSON serializes uint64 fields as strings (e.g. address permissions below comes back as "1").
detail has two representationsThe same activity event reaches you in two different encodings depending on the transport:
| Source | detail encoding |
How to read |
|---|---|---|
Guild API planet-activity catalog (/all, /planet/, /category/) |
JSON-encoded string | JSON.parse(row.detail) before use |
Guild API GET /api/planet-activity/player/{id}/page/{n} |
string and object | row.detail is still the string; row.detail_json is the parsed object (or null) |
| NATS / GRASS realtime stream | already-parsed object | use message.detail.* directly |
Verified: GRASS frames are parsed once via message.json() in webapp src/js/framework/GrassManager.js, and listeners access messageData.detail.* as an object. The REST planet-activity rows come straight from a PostgreSQL detail column and arrive as a JSON string. An integrator consuming both must branch on the source.
GRASS grid/planet subjects carry the owner
player_id(added 2026-07-07). Subjects arestructs.grid.{object_type}.{object_id}.{player_id}andstructs.planet.{planet_id}.{player_id}(literalnoPlayerwhen the owner can’t be resolved), and every such payload includes a top-levelplayer_idfield — so you can filter by owner from the subject without parsing. Because NATS*matches exactly one token, subscribe with the trailing wildcard:structs.planet.{planet_id}.*(one planet) orstructs.planet.>/structs.grid.>(all). A barestructs.planet.*matches nothing now. Verified in structs-pgdeploy/trigger-grass-planet-activity-20260707-add-owner-player-id.sqlanddeploy/trigger-grass-grid-20260707-add-owner-player-id.sql; the webapp listener matches the suffixed subjects insrc/js/framework/GrassManager.js.
There is also a field-casing split inside detail: most struct events use snake_case keys (struct_id, defender_struct_id), but struct_attack uses camelCase (see next section).
struct_attack event detail schemaAttacker context is flat at the top of detail; per-projectile outcomes are in
eventAttackShotDetail[]. This excerpt is from the pinned release keeper’s
single-shot survivor capture (unrelated fields omitted):
{
"attackerStructId": "5-1",
"attackerStructType": "Health event attacker",
"attackerStructTypeId": "800",
"attackerStructOperatingAmbit": "land",
"weaponSystem": "primaryWeapon",
"attackerPlayerId": "1-1",
"attackerHealthBefore": "6",
"attackerHealthAfter": "6",
"attackerHealthMax": "6",
"eventAttackShotDetail": [
{
"targetPlayerId": "1-2",
"targetStructId": "5-2",
"targetStructType": "Health event target",
"targetStructTypeId": "801",
"evaded": false,
"evadedCause": "noUnitDefenses",
"blocked": false,
"blockedByStructId": "",
"damageDealt": "2",
"damage": "2",
"targetHealthBefore": "5",
"targetHealthAfter": "3",
"targetHealthMax": "6",
"targetDestroyed": false,
"targetCountered": false,
"targetCounteredDamage": "0"
}
]
}
Type names and enum labels are strings in this JSON. attackerStructTypeId and
targetStructTypeId are separate decimal-string IDs. Do not use the TypeScript
binary enum representation as a description of the GRASS JSON payload.
targetPlayerId belongs to each shot. The attribution projection expands the
array to identify each target player.damageDealt is the projectile’s rolled damage. damage carries net volley
damage only on the final projectile row; earlier rows carry zero and unchanged
observed target/blocker health. Do not sum both quantities as damage.*HealthBefore/After/Max are keeper-observed values, preserved by sync-state.
Overkill cannot make health negative. A target’s final health can include
rebound from an explosive attacker killed by that target’s counter.targetDestroyed is true. Its interim
health is max(0, targetHealthBefore - damage), or unchanged if blocked, evaded
or evaded by planetary defenses. Apply final health/destruction after rebound.eventAttackDefenderCounterDetail[].stub: "true" instead of detail.
Retrieve the exact event with its
complete timestamp, planet and sequence; the authenticated response has
object-valued data.detail. Preserve microseconds and validate all key fields.Combat shape verified against structsd 96cea3a, sync-state d0b5924 and webapp
e326b0af, including 14 captured release events through PostgreSQL/GRASS and
exact-event HTTP acceptance. This does not change other sections’ review baselines.
See combat.md for the resolution order, chain-events.md for the Tendermint event, and api/streaming/event-schemas.md for the GRASS catalog.
Struct health and the numeric status bitmask are NOT on the base struct row. They live in struct_attribute rows and are only joined by some endpoints.
| Source | Returns health? |
Returns numeric status? |
|---|---|---|
Guild API catalog GET /api/struct/list/{all\|owner\|location}/... |
No | No |
Guild API bespoke GET /api/struct/player/{id}, GET /api/struct/{id} |
Yes (joined, default 0) | Yes (joined; missing attribute is 32 if is_destroyed, else 0) |
Chain LCD struct entity (GET /structs/struct/{id}) |
Yes (structAttributes.health) |
Yes (status) |
The catalog list endpoints return only base columns: id, index, type, creator, owner, location_type, location_id, operating_ambit, slot, is_destroyed, destroyed_block, created_at, updated_at (verified in webapp TableReadManager::structListAll/ByOwner/ByLocation). To get HP, built-state, or the build clock you must use a bespoke endpoint or the chain entity, where structAttributes exposes health, isBuilt, blockStartBuild, and status.
The numeric status is a StructState bit-flag, not an enum. Decode it with the canonical table in building.md — Status field (numeric) (Online = status & 4, Destroyed = status & 32; e.g. 35 is a destroyed struct). The catalog list’s is_destroyed boolean is the only destruction signal on the base row. Bespoke reads keep recently destroyed structs until STRUCT_SWEEP_DELAY elapses.
See api/webapp/struct.md for full response shapes.
/structs/address/{addr} response shapeThe chain LCD address query returns a flat object with playerId top-level (camelCase) — not nested under an Address wrapper:
{ "address": "structs1...", "playerId": "1-11", "permissions": "1", "proofNonce": "0" }
Verified in proto/structs/structs/query.proto (QueryAddressResponse { string address; string playerId; uint64 permissions; uint64 proofNonce; }, route /structs/address/{address}). permissions and proofNonce are uint64 → serialized as strings. A common polling bug is looking for the player id under a nested key; it is top-level. proofNonce is the next nonce the chain expects in an address-register proof for that address; it is burned on each successful registration and survives revoke, so never hard-code 0.
address-register proof string is chain-boundThe message a new key signs for address-register is:
CHAIN<chain-id>|REGISTERADDRESSPLAYER<player-id>ADDRESS<address>NONCE<proofNonce>
literally, with no separators other than the | after the chain id (for example CHAINstructs-testnet-1|REGISTERADDRESSPLAYER1-11ADDRESSstructs1abc…NONCE0). Read <proofNonce> from /structs/address/{addr} immediately before signing. A proof built for another chain id, another player, or a stale nonce fails with an invalid-proof error, and the ante rejects a second registration attempt for the same address in the same block (2033). The guild proxy-join proof is a different string (GUILD{id}ADDRESS{addr}NONCE0) and is unchanged — see the next section.
Every live number about an object — capacity, load, ore, power, lastAction — is a grid attribute, stored separately from the object record. The single-entity query joins them; the *All list query does not.
// single: record + grid attributes
gridAttributes := k.GetGridAttributesByObject(ctx, req.Id)
return &types.QueryGetAllocationResponse{Allocation: allocation, GridAttributes: &gridAttributes}, nil
// *All: bare records only
return &types.QueryAllAllocationResponse{Allocation: allocations, Pagination: pageRes}, nil
Verified in x/structs/keeper/query_*.go for player, struct, substation, planet, reactor, provider, and allocation: GetGridAttributesByObject appears in the single-entity handler and in no *All handler.
The practical consequences:
allocation-all never reports power. Allocation power is a grid attribute, so a list row looks like a zero-power allocation. Fetch the individual allocation for its real value. (This is why Structs Desktop’s guild_power.rs::find_dynamic_allocation lists to find the ID, then GETs it.)player-all. Charge is derived from the lastAction grid attribute — see Charge is per-player.Compounding this: grid attributes are uint64 with omitempty, so a zero-valued attribute is absent from the JSON entirely. Treat a missing key as 0 rather than as an error or an unsupported field.
rate infix. Weapon shot-success fields are primaryWeaponShotSuccessRate{Numerator,Denominator} / secondaryWeaponShotSuccessRate{Numerator,Denominator} — note Rate in the middle. Mis-keying as primaryWeaponShotSuccess{Numerator,Denominator} reads undefined/null and silently zeroes your combat math. Verified in proto/structs/structs/struct.proto (fields 22/23, 34/35).primaryWeaponShotSuccessRateNumerator). The Guild Stack PostgreSQL / Guild API uses snake_case column names (primary_weapon_shot_success_rate_numerator). Key your parser to the source you are reading.omitempty. primaryWeaponGuaranteedShots / secondaryWeaponGuaranteedShots exist on StructType (fields 67/68) but are 0 for every type except the Starfighter secondary (= 1), and zero values are omitted from JSON. A struct_type payload with no guaranteed-shots key does not mean the field was removed — it means the value is 0. See combat.md.There are two different ambit numbering schemes; conflating them produces an invalid int32 error on build.
| Scheme | Values | Used by |
|---|---|---|
| Enum | none=0, water=1, land=2, air=3, space=4, local=5 | Transaction messages: MsgStructBuildInitiate.operatingAmbit, MsgStructMove.ambit; a struct’s stored operatingAmbit |
| Reach bitmask | none=1, water=2, land=4, air=8, space=16, local=32 | StructType.possibleAmbit, primaryWeaponAmbits, secondaryWeaponAmbits (weapon reach masks) |
When you build or move, pass the enum (the CLI accepts the lowercase name space|air|land|water, which maps to enum 4/3/2/1). The bitmask values (2/4/8/16) are only for interpreting possibleAmbit and weapon-reach fields. Verified in proto/structs/structs/keys.proto (enum) and x/structs/types/keys.go (Ambit_flag bitmask). See building.md.
playerInventory.rocks on /structs/player/{id} is the spendable ualpha in the player’s vault — a deterministic protocol account resolved by GET /structs/vault/{ownerId} (ownerId, address, provisioned). Refined Alpha is minted there (EventAlphaRefine.vaultAddress), and reactor infusion, generator fuel, agreement collateral, Central Bank mint/redeem/convert and rank purchases all debit a vault. Consequences for integrators:
/cosmos/bank/v1beta1/balances/{vaultAddress}, not the key’s balance, for “how much Alpha does this player have”.player-send to it) or move Alpha out (vault-send, player-send from the vault address) with a key that holds PermTokenTransfer on the owner.0-N) hold the guild’s founding tokens, mint output and rank-sale revenue; guild-bank-mint never touches the signer’s own funds.playerInventory has exactly one key (rocks). Stored ore is the grid attribute ore, which omitempty drops when zero.See energy.md — Vaults.
charge = currentBlock - lastActionBlock, per-player, and any charge-consuming action resets it to 0. The ante also refuses a second charge-consuming message from the same player in one transaction (2020) or one block (2021), so a batch of build-initiates must be spread across blocks even though each costs only 1. The per-action “cost” is a minimum threshold, not a balance you draw down or bank. You cannot stockpile charge to burst several expensive actions; idling past your next action’s cost gains nothing. Plan combat as single actions spaced ~1 block per charge apart. A dashboard “Charge: N” is the current currentBlock - lastActionBlock, not a wallet. See building.md.
capacity_exceeded covers two different build checksstruct-build-initiate raises one error string — cannot handle new load requirements (required: X, available: Y) (structured error key capacity_exceeded) — for two unrelated gates. The numbers tell them apart:
required / available look like |
Gate | Meaning |
|---|---|---|
Tiny integers, often equal (e.g. 1 / 1) |
Per-player build limit | required is the struct type’s build limit, available is how many you already own. Most planet structs and the Command Ship cap at 1; only Orbital Shield Generator, Ore Bunker, and fleet combat structs stack. |
| Large values (hundreds of thousands to millions) | Power capacity (milliwatts) | required is the struct’s BuildDraw, available is remaining capacity (capacity + capacitySecondary) - (load + structsLoad). |
Do not assume the error is always about power — a 1/1 is the build-count limit, not a power shortage. Verified in x/structs/keeper/msg_server_struct_build_initiate.go (build-count and CanSupportLoadAddition checks) and x/structs/types/errors_structured.go (capacity_exceeded). See building.md.
The guild proxy signup flow (sign GUILD{id}ADDRESS{addr}NONCE0 — the proxy proof has no chain-id prefix and its nonce is not the address-register proofNonce → POST /api/auth/signup → guild fronts MsgGuildMembershipJoinProxy → poll /structs/address/{addr} for the player id) is safe to re-run. Re-running for an address that already joined returns {resource_already_exists}. Treat this as success (adopt the existing player) rather than a hard failure. See structs-onboarding.
Private /api/ routes accept a session cookie or an opaque bearer from
POST /api/auth/token. Both login endpoints require the same signed wallet proof,
hex-encoded compressed pubkey/raw signature and a fresh timestamp. An invalid bearer
does not fall back to a valid cookie. Logout invalidates the presented session and
revokes the presented token; chain address authority is separate.
Guild profiles, names, directory, rosters, member counts, power stats and completed planet counts are explicitly public GET/HEAD at the exact paths listed in auth.md. Anonymous cross-origin callers omit credentials and tokens. Signup, timestamp, settings, onboarding events and the public native proof/registration routes also retain public access.
Struct, player, reactor, ledger and planet-activity reads remain authenticated. Device list/count/detail, metadata, pending consent and activation management are owner-scoped. SQL-only edits of confirmed permissions return 410; use the native transaction and confirmed indexing. See player-address.md.
Auth scope reviewed against webapp integration 5991ca95; check the actual guild
API deployment before relying on these contracts.
Power/grid integrations trip on where the numbers live and how the messages are shaped.
Planet.sector and gridAttributes.connectionCapacityMaximum are decimal strings. PostgreSQL stores planet.sector (also on view.planet; webapp detail exposes data.sector) and the cap in grid.val under attribute ID 15, label connectionCapacityMaximum. The cap is exact uint64 mW; zero means unlimited. GRASS value_p is raw mW and value is truncated whole watts (div(val,1000)); preserve numeric precision when decoding JSON. There is no dedicated cap stat hypertable. See database contracts.gridAttributes sub-object, not the entity wrapper. For player, substation, and reactor LCD entities, capacity, load, structsLoad, connectionCapacity, and connectionCount are under gridAttributes. There is no capacitySecondary key on the wire — secondary capacity is the connected substation’s connectionCapacity (see energy.md). Top-level wrapper fields are the non-grid ones — reactor defaultCommission and validator, and owner on Reactor/Substation/Guild."1512960000"), including everything in gridAttributes. Parse before doing math — a unit is milliwatts (see energy.md — Units).guild entity carries the power entry points: primaryReactorId (field 9) and entrySubstationId (field 10) — start here to resolve a player’s power infrastructure. Verified in proto/structs/structs/guild.proto.location_type, operating_ambit, slot, is_destroyed, type/type_name but not isBuilt/blockStartBuild — read the chain struct entity (structAttributes) for those (see “Where struct HP and status live” above).Message field shapes (verified in proto/structs/structs/tx.proto):
| Message | Fields | Gotcha |
|---|---|---|
MsgReactorInfuse |
creator, delegatorAddress, validatorAddress, amount |
amount is a single Coin (not a list); infusing is a delegation to the reactor’s validator address. |
MsgAllocationCreate |
creator, controller, sourceObjectId, allocationType, power |
No destinationId — the destination is set later via connect. |
MsgAllocationUpdate |
creator, allocationId, power |
Only dynamic allocations are updatable. Growing an existing allocation releases its own current power before the capacity check — an increase on a live allocation no longer false-errors as capacity_exceeded (create-vs-update asymmetry, allocation_cache.go SetDynamicPower). |
MsgSubstationAllocationConnect |
creator, allocationId, destinationId |
The substation id goes in destinationId — there is no substationId field. |
See energy.md for the grid mechanics behind these shapes.
struct_type DB field shapesTwo struct_type shape changes in the Guild Stack (structs-pg) that tools read:
generating_rate is a formatted column. The raw chain value now lives in generating_rate_p, and generating_rate is a generated column equal to generating_rate_p * 1000 (same _p/formatted split as ledger/infusion precision columns — not structs.grid, which stores a single val). For the raw per-gram rate the gameplay docs quote (Field Generator 2, Continental Power Plant 5, World Engine 10), read generating_rate_p; generating_rate is the scaled representation. Verified in structs-pg deploy/table-struct-type-20260602-add-generating-rate-precision.sql.struct_type exposes primary_weapon_armour_piercing and secondary_weapon_armour_piercing (chain StructType.primaryWeaponArmourPiercing / secondaryWeaponArmourPiercing, structsd v0.18.0) — read these rather than inferring from the struct class. Only the Battleship sets them today. Verified in structs-pg deploy/table-struct-type-20260612-add-armour-piercing.sql. See combat.md.Use raw precision columns for arithmetic (amount_p, fuel_p, power_p, etc.); formatted columns and UNIT_DISPLAY_FORMAT() are presentation surfaces. At structs-pg f66fd81 the display ladders are:
mW, W (10³), KW (10⁶), MW (10⁹), TW (10¹⁵);g, Kg (10³), Tg (10¹²);ualpha: μg, mg (10³), g (10⁶), Kg (10⁹), Tg (10¹⁸).Scaling uses exact numeric powers, negative values use their absolute digit count for unit selection, and trailing zeroes are trimmed. Exact zero intentionally renders in the display unit: 0g for ualpha, 0W for milliwatts, 0g for ore, and the guild token’s display denomination. Older deployments can return wrong/NULL high-unit labels, so co-version the PG schema with readers that assert formatted output.
Profile pictures are a moderated player UGC attribute alongside username, and the pending-player signup flow now threads pfp render hints too. PLAYER_PENDING_JOIN_PROXY builds the signed guild-membership-join-proxy ugc argument from up to three keys: player-name (from username), player-pfp (from pfp), and player-pfp-client-render-attributes (from the pfp_client_render_attributes column — the column was renamed from pfp_cr_attributes, and the ugc key was lengthened from the short player-pfp-cr-attributes form to match). Committed username/pfp surface on structs.player via GRASS player_consensus. Verified in structs-pg deploy/trigger-player-pending-20260612-pfp-cr-attributes-inclusion.sql, …-20260617-rename-pfp-cr-attributes.sql, …-20260617-ugc-key-long-name.sql. The pfpClientRenderAttributes field is self-service (not guild-moderatable); moderation of name/pfp follows the ugc_moderated path — see ugc-moderation.md.
Every permission failure renders the same string regardless of which flag was actually checked:
...calling player (1-1) has no administrate permission on object (1-61)...
The word “administrate” is hardcoded — it is a fixed literal passed to NewPermissionError on every denial path, not a report of the bit that failed (verified: PermissionCheck in x/structs/keeper/permissions_context.go passes "administrate" in all four return-error branches). So an “administrate” error does not mean PermAdmin (2) was required. To find the real missing bit, map the failing message handler to its required permission via the handler permission table. Example: a substation-player-migrate denial on a player object is a missing PermSubstationConnection (1024) on that player, not PermAdmin — see energy.md.