Docs / SDK

Health and guard

status() and guard() for bots.

status()

Reads the newest block and the counter, and returns:

  • health: fast (130 ms or less between blocks), normal, slow (over 400 ms) or stalled (no new block for 10 s).
  • blockAgeMs: how old the newest block is (timestamps are whole seconds, so ±1 s).
  • avgBlockMs, capacity, receiptP50, finalityLagS: the counter's numbers.
  • ok: false only when stalled.

guard()

await elysium.guard({ maxBlockAgeMs: 3000, maxAvgBlockMs: 500 });
// throws "Elysium looks stalled: newest block is 12 s old"

Put it before anything that should not run on a stuck chain: a liquidation, an arbitrage, a market-making requote, a bridge transfer.

Without the SDK

GET /api/status returns the same object, with HTTP 503 when the chain is stalled, so uptime monitors can watch it directly. See Status and badge.