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
| Party | Holds | Can do |
|---|---|---|
| Owner | A normal Stellar account (Freighter, xBull, Lobstr) | Deploy the wallet, fund it, register agents, approve or deny holds, withdraw, pause everything |
| Agent | An ed25519 key, 0 XLM | Sign payment requests. Nothing else |
| Wallet contract | The USDC | Approve or refuse each payment against the agent's policy |
| Facilitator & relayer | XLM for fees | Submit and pay for transactions. It can't move funds the wallet didn't authorise |
| Seller | A Stellar address | Ask 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:
- Kill switch: the wallet isn't paused.
- Replay guard: this
request_idhasn't been used. IDs are kept for 7 days. - Signature: the ed25519 signature matches a registered agent key.
- Shape: the transaction is exactly one USDC
transferfrom this wallet, with no sub-invocations. - Agent state: the agent is
Activeand its key hasn't expired. - Seller: the recipient is on the agent's allow-list.
- 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
- Policies: every field and its limits.
- Holds: the approval flow.
- Zero-XLM relayer: why the agent never needs gas.