IntentTtl

object IntentTtl

Sizes a transaction's intent TTL to the live chain limit.

The node rejects an intent whose TTL sits more than the chain's global_ttl ahead of chain time (custom error 182 / IntentTtlTooFarInFuture). That ceiling varies enormously by network — a localnet runs ~100s, PreProd ~1h — so a fixed 30-minute window silently overshoots a tight localnet by ~18x and every tx is rejected. These helpers derive a window that fits whatever global_ttl the chain actually reports (ContractRuntime.ledgerGlobalTtlSeconds).

Functions

Link copied to clipboard
fun ttlSeconds(nowMs: Long, globalTtlSecs: Long?): Long

Absolute intent TTL (seconds since epoch): nowMs anchored + the adaptive window.

Link copied to clipboard
fun windowSeconds(globalTtlSecs: Long?): Long

TTL window in seconds that fits under globalTtlSecs with MARGIN_SECS of headroom, capped at MAX_WINDOW_SECS. Falls back to half the ceiling if the margin would underflow (a pathologically small global_ttl), and to FALLBACK_WINDOW_SECS when the ceiling is unknown.