Skip to Content
KryptWarden Developers
Concepts

Policies

The limits each agent gets, and the rules the contract applies to them.

Each agent registered on a wallet has one policy. The owner sets it with register_agent and changes it with update_policy. Each change bumps the agent's policy_version, which is stamped on every hold and ledger entry so you can tell which rules applied.

Fields

Prop

Type

Anything outside these ranges fails with InvalidPolicy (103), or TooManyAllowedSellers (104) for more than 32 sellers.

How the budget is counted

  • The day is a UTC day. day_index = ledger_timestamp / 86,400. The first payment after midnight UTC resets spent_today to 0.
  • Open holds count against the budget. A pending or approved hold reserves its amount. Settling it moves the amount into spent_today, while denying it or letting it expire frees the reservation.
  • Projection, not after-the-fact. The contract refuses a payment if spent_today + active holds + amount > daily_budget. You can't overshoot by a single large payment.

Agent status

StatusCan pay?Owner action
ActiveYesresume_agent
PausedNo, but the policy and history are keptpause_agent
RevokedNo, permanentlyrevoke_agent

On top of these, the owner can pause the whole wallet with pause. That freezes every agent, every payment and every new hold until unpause.

Changing a policy safely

  • update_policy applies straight away to new payments.
  • Holds keep the policy_version they were created under, so the audit trail shows which rules applied.
  • To cut an agent off immediately, pause_agent or revoke_agent is faster and clearer than shrinking its budget.

On this page