Skip to content
docsv0.12.0

NonceLedger

Remembers which authorizations have been spent, for as long as they could still be replayed. Only needs to remember for the freshness window: past it, the authorizer rejects on age anyway, so a ledger that grows forever is storing proof of something already impossible.

NonceLedger::spend()

abstract public function spend(string $nonce, int $ttlSeconds, int $now): bool

Marks the nonce used and reports whether this call is the one that used it. Must be atomic. A check-then-write leaves a gap where two processes both read "unused" and both proceed — and the operations worth signing are precisely the ones worth not running twice.

Parameters

Parameters of spend()
NameTypeDescription
$noncestring
$ttlSecondsint
$nowint