const DaySeconds
DaySeconds is the length of one daily budget window, in seconds. Days are wall-clock UTC days counted from the Unix epoch.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package agentvault is the reusable spend-cap library behind the AgentVault realm: the first wallet an AI agent cannot...
Package agentvault is the reusable spend-cap library behind the AgentVault realm: the first wallet an AI agent cannot drain.
It is pure: no realm state, no chain calls, no imports from any realm. Every function takes explicit inputs (including the current unix time for day rollovers) so the logic is unit-testable without a chain. The vault realm in gno.land/r/g16740fm9kd28luuktn3g42jfq3r998fm35chclv/agentvault stores AgentBudget values and calls these functions; any other realm can import this package and get the same caps.
DaySeconds is the length of one daily budget window, in seconds. Days are wall-clock UTC days counted from the Unix epoch.
ApplySpend records a spend that already passed CheckSpend.
CheckSpend reports whether amount may be spent under this budget. It does not mutate the budget; call RefreshDay first, then ApplySpend after a successful check. The order of the checks is deliberate: the cheapest, most specific rejection comes first so the logged reason tells the agent exactly which limit it hit.
DayIndex returns the unix day for a unix timestamp.
EscrowRefundable reports whether a held escrow may be refunded: the deadline block has passed and it is still held. A released or already-refunded escrow is never refundable again.
EscrowStatusString renders an escrow status for the log and the Render page.
RefreshDay resets SpentToday when the day has rolled over. Call it before CheckSpend so a stale day never blocks a new day's spend. It only ever moves the day forward and clears the spent amount; it never restores spent funds.
RemainingToday returns how much of the daily cap is left.
ValidateCaps reports "" when a cap pair is usable, otherwise the reason it is not. Both caps must be positive and the per-transaction cap must not exceed the daily cap (a per-tx cap above the daily cap could never be spent in full).
NewBudget builds a budget. Callers must validate first with ValidateCaps; an invalid pair panics rather than silently installing a budget that can never be spent.
AgentBudget is one agent's spend limit. It is a plain value type: the owning realm stores it and passes it back in. SpentToday and DayIndex are bookkeeping the realm must not forge; RefreshDay is the only function that moves them, and only forward in time.
Attempt is one entry in a vault's append-only spend log. Allowed false means the guard stopped the spend; Reason names why, so the blocked attempt is evidence, not just a failed transaction.
Escrow is one name payment held by the vault until the named recipient confirms delivery (release) or the owner refunds it after the deadline block (refund). The coins never leave the vault while held; release sends them, refund only flips the status.
EscrowStatus is the lifecycle state of a name payment held in escrow.
Imports nothing.