Transactions, Gas, and Fees

Purpose: Explain how the ante handler routes Structs gameplay transactions and Cosmos staking transactions through a free-gas path while everything else continues to pay fees in ualpha.


TL;DR


What “free” actually means

Cosmos SDK ante decorators run before the message handler executes. Structs’s custom ante chain (app/ante/ante.go) inserts a GasRouterDecorator early in the chain that checks every incoming transaction:

  1. If IsFreeTransaction(msgs) – every message URL starts with /structs.structs.Msg AND none is MsgUpdateParams or a member of PricedStructsMessages (MsgGuildCreate, MsgReactorRestart) – the gas meter is replaced with a free meter capped at FreeGasCap (default 20_000_000).
  2. Else if IsFreeStakingTransaction(msgs) – every message URL is one of the six entries in FreeStakingMessages – the gas meter is replaced with a free meter capped at FreeStakingGasCap (default 40_000_000), and a per-address per-block throttle gates how many of these can land.
  3. Otherwise the standard SDK gas meter is used and fees flow through ConditionalMempoolFeeDecorator + ConditionalFeeDecorator, which behave like the upstream SDK fee decorators.

Both ConditionalMempoolFeeDecorator and ConditionalFeeDecorator short-circuit when the context flag IsFreeTx(ctx) is set, so free transactions are never charged a fee even if the user accidentally attaches one.

--gas auto (or --gas-adjustment 1.5) is still required because the SDK simulator must produce a gas estimate; if the estimate exceeds the meter cap (free or paid) the tx is rejected with out of gas. Free does not mean infinite.


Free Structs gameplay messages

Anything in KnownStructsMessages (defined in app/ante/maps.go) qualifies for the free-gas path, except MsgUpdateParams (governance) and the priced MsgGuildCreate / MsgReactorRestart operations. The list covers:

Excluded from the free path:

If you want to see the canonical, complete list, read KnownStructsMessages in .references/structsd/app/ante/maps.go.


Free staking messages

The chain treats staking as a first-class gameplay action because reactor staking is what creates and powers a player. To remove that economic friction the following six messages are free, against a separate 40 M meter:

Constraints:

The staking throttle also rejects two listed staking operations from the same address inside one transaction (structs-ante 2042), and another in the same block (2043). It follows the message even in a mixed paid transaction. Batching or paying gas does not bypass it. Multi-message Structs reactor withdrawal has its own release rules; do not confuse those messages with raw Cosmos staking.


Anything not classified as free runs through the standard fee path:

These pay fees in ualpha like any other Cosmos SDK chain. Set --fees or --gas-prices accordingly.


Direct messages and nested execution

Submit Structs gameplay messages directly. The ante guard rejects Structs messages nested inside authz.MsgExec or group proposals, including mixed nesting, with structs-ante/2004 (ErrNestedStructsMessage). It inspects every group submission, stored proposals referenced by group MsgExec, and MsgVote with EXEC_TRY. Voting without execution and withdrawing proposals remain available.

Traversal allows depth 8 and at most 256 visited messages across the transaction, including roots and repeated proposal references. Cycles, malformed containers, nil nested messages, and unreadable proposal references fail closed. Stored proposal inspection runs after fee deduction and signature verification under the transaction gas meter. CheckTx, ReCheckTx, simulation, and delivery enforce the same boundary.

Ordinary non-Structs group/authz operations are supported within these bounds. An execution reference must resolve when ante runs: for a native group proposal created and executed in one transaction, use submission’s EXEC_TRY, rather than a separate MsgExec referring to an unstored proposal. Governance’s authority-gated MsgUpdateParams path is supported.

Source: app/ante/nested_msg.go and app/ante/ante.go.


Other ante checks that still apply

Even when a transaction is free, the rest of the ante chain still runs:

The DynamicPermissionMessages set (e.g. all UGC messages, address/permission management, guild membership voting flows) skips the ante-level permission check and lets the handler enforce the right permission, since the bits depend on runtime fields. Dynamic permission resolution is separate from fee classification: MsgReactorRestart is dynamic and priced. Evaluate the complete transaction against the fee maps.


Practical guidance


See Also

Ante review: official structsd v0.23.0 f6dc0047, app/ante/{ante,maps,nested_msg,gas_router,staking_throttle}.go. Other gameplay-specific examples retain their own mechanics references.