Skip to main content
Timers fire at a block height, and block time is only estimated from it. cowboy_sdk.std.clock measures the chain’s block rate in the actor’s own storage as the actor runs, and turns a block-time target into the height to arm a timer at.
  • height_at(storage, at_ms, max_blocks=MAX_TIMER_BLOCKS) is at least the next block and at most max_blocks ahead. The default, 2,500,000, sits below the default timer TTL (cip5.timer.max_ttl_blocks, 2,592,000). The TTL is governed, so on a chain that lowers it, pass your own max_blocks. A target further out lands early.
  • ms_per_block(storage) is the rate it uses. Until two calls at least MEASURE_BLOCKS (600) apart have measured it, the rate is BLOCK_MS (1,000). A measurement is clamped to 100 to 10,000 ms.
  • The measurement is one storage key, std.clock, holding [height, timestamp_ms, ms_per_block].
An estimate can land early or late. A handler whose work depends on the time itself compares runtime.get_timestamp_ms() with its target when the timer fires, and re-arms with height_at if it is early. For a fixed period, @every and runtime.schedule_after already re-arm an early timer for you. Use std.clock for a calendar target, such as the next 07:00 UTC.