Treasury Guard

A dollar budget for AI agents, not a wallet key

Visit Repo
Treasury Guard banner

About

## Challenges we ran into

**Two chains, no bridge.** Base cannot see BSV, and BSV script cannot read Base. So we had to be exact about where each rule is enforced. The BSV script enforces the keys: agent + watcher together, or the owner alone. The watcher enforces the dollar limit: it reads the SPEND intent from Base itself and checks the raw transaction byte by byte. `settle()` on Base is a record, not a cross-chain proof. We proved the owner's exit on mainnet before we funded the agent path.

### BSV

- **Fees grew with the vault inputs (intent 11).** Several deposits gave the withdrawal several inputs, and the fee went past the fixed 100-sat reserve. The outflow went over `maxSats` and the watcher refused, which was correct. The reserve now grows with the number of inputs (about 19 sats each, measured). - **HTTP 431 after paying (intent 12).** The BEEF payment proof in the `x-bsv-beef` header was larger than Node's 16 KB header limit. The sats were paid but no data came back. The demo merchant now accepts headers up to 1 MB. - **A deposit that was never broadcast (intent 13).** BSV Desktop returned a txid, but the network never saw the transaction, and the watcher refused a coin WhatsOnChain did not know. Owner transactions are now checked on the network and posted again from the same signed BEEF, and a run spends only coins the watcher can see. - **Crash safety.** The watcher writes its journal (fsync, rename, checksum) before a signature leaves it, so one intent can never become two transactions. A replay gets HTTP 409.

### API3

- **Freshness and replay.** A signed price is fresh for 5 minutes and is accepted only once. So the tamper test runs `checkPrice` as a free `eth_call` on a judge vault that has the same Airnode, request and age rules and has never accepted a price. - **A distinct WrongRequest error.** A response for another feed (BTC/USD) only recovers an unrelated signer, so the contract checks the request hash before it recovers the signer. - **Two laptops.** The agent key that can create SPEND intents stays on the API3 laptop. The BSV laptop calls it through a small token-protected service. Its tunnel dropped twice (QUIC timeouts) until we switched it to HTTP/2.

### Agent and scope

- The model decides whether a purchase serves its task, but a model can be talked into anything. So the caps, the merchant allowlist and the price checks live in a rule-based guardian and in the watcher, not in the prompt. - We built a BSV-backed stablecoin (CDP) prototype, but we left it out. BSV script cannot see the debt or the price, so it would need a trusted watcher holding the collateral. That is custody, and this track requires funds that are not held in custody.

## The problem it solves

AI agents now pay for APIs, data and compute on their own. Giving an agent a wallet key is a blank cheque: one prompt injection or bug and the wallet is empty. Owners think in dollars, not sats, and need a hard limit the agent cannot talk its way around.

**Treasury Guard gives the agent a dollar budget instead of a key.**

### How it works

- **Vault on BSV mainnet.** The owner's sats sit in a script: `(agent AND watcher) OR owner`. The agent cannot spend alone. The owner can always exit alone, with no agent, no watcher and no Base transaction (proven on mainnet). - **Budget on Base Sepolia.** The agent buys a signed BSV/USD price from an API3 Airnode (CoinPaprika, paid over x402). `TreasuryGuard.sol` checks the signer, the request, the age (5 min) and replay, then turns dollars into a SPEND intent with a hard `maxSats` under a daily budget. - **Watcher.** It reads that intent from Base itself and checks the real BSV transaction byte by byte: vault inputs only, exactly one Agent Float output, change back to the same vault, the TGv1 receipt, outflow + fee ≤ `maxSats`. It journals the intent and only then co-signs. One transaction per intent; a replay gets HTTP 409. The watcher can block, never take. - **Agent payment.** The agent's model (DeepSeek or Claude) decides whether a purchase serves its task; a rule-based guardian enforces the merchant allowlist, the price and the caps; the agent pays an HTTP 402 API in sats from its float. `settle(intent, txid)` records the BSV txid on Base: a record, not a cross-chain proof. - **DeFi rail.** Atomic swap-and-pay turns sats into a token and pays a token-only merchant in one BSV transaction.

### Who uses it, and how

A team runs a research or trading agent whose control logic lives on Base and gives it $1 a day. The owner funds the vault from BSV Desktop; the agent asks for budget with a signed price; the watcher releases exactly that much; the agent pays per call. A live dashboard shows each step: run the agent, refuse a replay, run the tamper test, exit alone.

### What it brings to BSV

Agents pay small amounts, often. On mainnet a vault withdrawal cost about 40–80 sats in fees and an HTTP 402 payment 23 sats (≈ $0.000004). Treasury Guard brings agent teams and their budgets from an EVM chain to BSV micropayments without custody, using the BSV SDK, Wallet Toolbox, BEEF/SPV payments and BSV Desktop as the owner's wallet.

### Signed data (API3)

- **Who relies on it:** the vault owner. The signed BSV/USD price decides how many sats one dollar may release. - **If it is forged:** a lower price means more sats per dollar; a stale or replayed price lets the agent overspend. The contract refuses edited, stale, wrong-request and wrong-signer responses (tamper test: one valid, four rejected). - **Data we could not find:** a BSV/USD feed on Nodary, so we used CoinPaprika's Airnode.

### Proof

- Contract: `0x8e38cc6B1Bd1f0D25357066cd0036f28fd1f7773` (Base Sepolia) - Live run, intent 16: [withdrawal](https://whatsonchain.com/tx/76df78096bb06e2acecc5d7a109521a71a7809a379a1912934ccf8fcd994dbc5) → [HTTP 402 payment](https://whatsonchain.com/tx/2b38c983cd3663648f9ed8812a4f67c268459053dcf4d4b9a16fc7dd8c361892) - Owner exits alone: [db5ca41c…](https://whatsonchain.com/tx/db5ca41c82c4506f66614193b6c2ccf5b84f3d7afffcda4f1a588b09edf7d41e) - Swap-and-pay: [ee2a3896…](https://whatsonchain.com/tx/ee2a38964df993af6cd48f5f51d1ce0c07c7bf454363735341288d7f71bf8e8c) - All runs: `bsv/docs/evidence/RESULTS.md` in the repository

Screenshots

Treasury Guard screenshot 1Treasury Guard screenshot 2Treasury Guard screenshot 3Treasury Guard screenshot 4Treasury Guard screenshot 5

Team

From the public Devfolio project page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

Not checked yet.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

VaultBreaker

AI agent capability broker protecting private keys via Ledger seed & Hedera on-chain spend limits

PayGuard x402 — Non-Custodial Spending Firewall & HTTP 402 Settlement Gateway for AI Agents

Non-Custodial Spending Firewall & HTTP 402 Settlement Gateway for AI Agents (Solana Devnet + HashKey Chain Testnet)