Skip to Content
KryptWarden Developers
Concepts

How it works

The path of one payment, and where each check happens.

KryptWarden builds on two Stellar features: x402, a way for an HTTP API to ask for payment with a 402 Payment Required response, and Soroban custom accounts, contracts that decide for themselves whether a transaction is authorised by implementing __check_auth.

The wallet is a custom account. The agent never holds the money. It holds a key that can ask the wallet to pay, and the wallet checks the request against the owner's policy every time.

The parties

PartyHoldsCan do
OwnerA normal Stellar account (Freighter, xBull, Lobstr)Deploy the wallet, fund it, register agents, approve or deny holds, withdraw, pause everything
AgentAn ed25519 key, 0 XLMSign payment requests. Nothing else
Wallet contractThe USDCApprove or refuse each payment against the agent's policy
Facilitator & relayerXLM for feesSubmit and pay for transactions. It can't move funds the wallet didn't authorise
SellerA Stellar addressAsk for payment with 402, then serve the paid response

One payment, step by step

If the policy says no, __check_auth fails, the transfer never happens, and the SDK throws a KryptWardenPaymentError. It also asks the relayer to write a PaymentRejected event, so the owner can see the attempt.

The policy gates

__check_auth runs these checks in order and stops at the first failure:

  1. Kill switch: the wallet isn't paused.
  2. Replay guard: this request_id hasn't been used. IDs are kept for 7 days.
  3. Signature: the ed25519 signature matches a registered agent key.
  4. Shape: the transaction is exactly one USDC transfer from this wallet, with no sub-invocations.
  5. Agent state: the agent is Active and its key hasn't expired.
  6. Seller: the recipient is on the agent's allow-list.
  7. Budget: the UTC day rolls over if needed, then the contract picks a path:
    • Fast path: amount ≤ auto-approve limit, and spent today + active holds + amount ≤ daily budget. Settles now.
    • Hold path: amount > auto-approve limit. It needs an approved hold for exactly this seller and amount, before the hold expires.

Each check maps to a contract error code. See Contract errors.

Where things are stored

  • On-chain (the source of truth): policies, spend for the current day, holds, used request IDs, and every event.
  • Indexer (a convenience): a Postgres copy of the events, so the dashboard can show history quickly. It never decides anything. The Overview page's reconciliation check compares the two.

Next

On this page