Docs/Examples/Parameter Alerter

ParameterAlerter (On-chain Audit Trail)

Snapshots tracked game-parameter values on every tick and emits an immutable audit record on any drift — tamper-proof proof against stealth nerfs.


Overview

ParameterAlerter tracks a set of named game parameters and creates an immutable audit trail of every change. On each AutoLoop tick, it snapshots all tracked values and emits ParameterChanged events for any that have drifted since the last snapshot. The audit log is permanently on-chain and verifiable by any observer.

PropertyValue
Base contractAutoLoopCompatible (no VRF)
VRF usageNone
Gas per tick~30k–80k (scales with tracked params and change count)
Sourceautoloop/src/agents/ParameterAlerter.sol
Tests28 passing (unit + fuzz)

Why AutoLoop Is Structurally Required

Stealth nerfs require no neutral snapshotter. Any human trigger can be delayed until after the operator has front-run the parameter change. For example:

  1. Operator decides to reduce drop rate from 10% to 3%
  2. Operator sells all items with the old drop rate
  3. Operator calls setParam("dropRate", 300) to update the contract
  4. Only then triggers the snapshot — which records the change "faithfully" but after the fact

AutoLoop's autonomous tick fires at the next interval regardless. The snapshot is taken before any human can act on it, and the audit trail begins at the committed time — not at the operator's convenience.

Mechanics

  • addTrackedParam(key, initialValue): registers a new parameter key with its starting value. Admin only.
  • setParam(key, value): updates a parameter's current value. Admin only (simulates operator changing a game setting).
  • progressLoop(): on each tick, compares currentParams[key] to lastSnapshotted[key] for every tracked key. Any difference emits ParameterChanged and pushes a ChangeRecord to the on-chain audit log.
  • getAuditLog(index): returns the full ChangeRecord struct — key, old value, new value, block number, timestamp.

Revenue Model

  • AutoLoop gas fee on each tick
  • No protocol fee (pure audit primitive)

Deploy

forge create src/agents/ParameterAlerter.sol:ParameterAlerter \
  --constructor-args 3600 \
  --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Args: checkInterval (seconds between snapshots). A 1-hour interval (3600) is typical for game parameters.

After deploy, register with AutoLoop and call addTrackedParam for each parameter you want to audit.

Dashboard

View ParameterAlerter on the AutoLoop Dashboard.