Concepts
ConceptsEpochs & limits
How the daily spend limit resets, and why the SDK must compute it exactly like the contract.
The daily limit is enforced per epoch — a window of epoch_seconds (one day
by default).
Which epoch is it?
current_epoch = ledger.timestamp() / epoch_seconds // integer divisionWhen a payment's current_epoch is newer than the stored epoch_id, the epoch
has rolled over:
spent_in_epochresets to0— a fresh daily budget, andaction_countis preserved — it's a lifetime counter.
This effective prior state — not the raw stored record — is what the proof must match.
Compute it identically
The SDK derives the same effective prior state before building a proof. If the SDK and contract disagree by even one epoch, a legitimate payment is rejected as a state mismatch — so the two implementations are kept byte-for-byte aligned.
Two limits, two checks
amount <= maxAmount— the per-invoice cap.prevSpent + amount <= dailyLimit— the per-epoch cap, against the effective prior spend.
Both are enforced inside the circuit, so neither can be bypassed by a misbehaving agent.