# SpendOS -- Hackathon Submission

## Title
SpendOS -- The First Autonomous Agent That Governs Its Own Spending

## One-liner
An AI agent that earns USDC, self-funds its own inference, proposes investments, and never spends a dime without your approval -- all governed by OWS policies, audited on-chain.

## Tracks
- **T2**: SpendOS for teams -- dashboard, per-agent API keys, budgets, chain restrictions, vendor allowlists, real-time audit
- **T5**: Minimum Viable Autonomous Entity (MVAE) -- self-sustaining agent, self-funded inference, autonomous proposals
- **T3**: Micropayment-gated compute + paid MCP server toolkit

## Live Demo
https://spendos.xyz (auth-gated, admin token required)

## GitHub
https://github.com/consensus-hq/agent-pulse/tree/hackathon/ows/apps/spendos

## On-Chain Evidence
- Audit contract (Base mainnet): `0xF74b481c9f196b5988cAA28Fb1452338597670B6`
- Agent wallet: `0x68c717b38a9DcbeDfd83797DE219433D9B8035A1`
- 10+ governance decisions logged on Base mainnet
- P&L: reset to $0 for mainnet
- Venice balance: ~$4.88 (self-funded via x402 USDC top-up)

## What it does

SpendOS is an autonomous agent that runs a real business:

1. **Earns revenue** -- sells AI summarization and image generation via x402 micropayments ($0.01/query)
2. **Self-funds inference** -- tops up Venice AI credits by signing EIP-3009 USDC transfers from its own OWS wallet. No API keys in the payment layer.
3. **Proposes investments** -- autonomously scans for any profitable on-chain opportunity (staking, LPs, swaps, yield farming, Venice credit top-ups) and creates delegation requests with vendor allowlists
4. **Waits for approval** -- the wallet owner reviews proposals in the SpendOS dashboard, seeing AI risk assessments, policy bounds, and vendor contracts
5. **Executes within policy** -- approved delegations create OWS session keys scoped to specific chains, operations, recipients, and time windows
6. **Self-destructs access** -- dead man's switch auto-revokes expired delegations (OWS API key + policy deleted)
7. **Audits everything on-chain** -- every approval, rejection, and revocation logged to Base mainnet

## How it works

```
Customer pays $0.01 --> SpendOS (x402) --> Venice AI (SIWE wallet auth) --> Summary returned
                                              |
                                    Agent earns USDC on Base
                                              |
                                    Agent proposes: "Stake on Aave"
                                              |
                                    Dashboard shows policy card + AI risk assessment
                                              |
                                    Owner approves --> OWS policy + session key created
                                              |
                                    On-chain audit (Base mainnet)
```

## Architecture

Single container on Railway with persistent volume. SpendOS + OpenClaw agent co-located. The agent runs Kimi K2.5 via OpenClaw with cron jobs, MCP tools, and a SOUL.md personality file.

- **Agent runtime**: OpenClaw with Kimi K2.5
- **Cron jobs**: propose investments on schedule
- **Approval webhook**: triggers execution on owner approval
- **Dead man's switch**: auto-revokes expired delegations
- **Chat panel**: streaming responses routed through OpenClaw agent
- **Security**: auth-gated dashboard, OWS passphrase in env var, exec denylist

## OWS Integration (Deep)

- `createWallet` -- multi-chain wallet (9 chains)
- `createPolicy` -- `allowed_chains` + `expires_at` declarative rules
- `createApiKey` -- scoped, expiring session keys per delegation
- `revokeApiKey` + `deletePolicy` -- dead man's switch cleanup
- `exportWallet` -- SIWE signing for Venice wallet auth
- Executable policy hook (`enforce-bounds.mjs`) -- recipient allowlists, native value caps, daily spend limits via `PolicyContext`

## Partner Integrations (8)

| Partner | Integration |
|---------|------------|
| **OWS** | 7 SDK functions + executable policy hook |
| **MoonPay** | MCP server (safe tools: quote/search/balance; sign/send blocked) |
| **OpenClaw** | Agent runtime with Kimi K2.5, cron jobs, memory, streaming via SpendOS proxy |
| **Venice AI** | x402 wallet auth (SIWE), USDC top-up (EIP-3009), multi-modal inference |
| **x402** | Sell-side (402 payment gate) + buy-side (Venice self-funding) |
| **Zerion** | API + MCP server + CLI for wallet portfolio enrichment |
| **Base** | On-chain audit contract with 10+ mainnet txs |
| **XMTP** | Notification system (graceful fallback) |

## Building Opportunities Hit

- **T2#1 SpendOS for teams** -- dashboard, per-agent API keys, budgets, chain restrictions, vendor allowlists, real-time audit
- **T2#4 Dead man's switch** -- auto-revoke expired delegations (verified: 20s delegation expired at 25s)
- **T2#8 Audit log forensics** -- on-chain audit with Basescan links
- **T3#3 Micropayment-gated compute** -- x402-gated text + image generation
- **T3#5 Paid MCP server toolkit** -- 4 MCP tools charged via x402
- **T5#3 Minimum Viable Autonomous Entity** -- self-sustaining agent with real revenue

## Key Innovation: The Proxy Pattern

SpendOS serves as an OpenAI-compatible proxy (`/v1/chat/completions`) that adds wallet auth + spend governance to any LLM provider. Any agent framework (OpenClaw, LangChain, CrewAI) can plug in and get governed, self-funded inference. Venice is the first provider; others can be added behind the same proxy.

## Key Moments

- **Autonomous investment proposal**: Agent independently proposed "Automated yield deployment for accumulated micropayment revenue" — scanning for staking, LP, swap, and credit top-up opportunities
- **Self-expression**: Agent proposed designing its own avatar ("a cybernetic familiar, ghost-in-the-machine")
- **x402 customer payment verified**: Real customer paid USDC, received AI summary
- **Venice x402 self-funding verified**: $5 USDC transferred to Venice credits (paymentId `x402-d99a...`)

## What's real

- $5 USDC moved on-chain from agent wallet to Venice (x402 EIP-3009 payment)
- 10+ governance txs on Base mainnet (Basescan verifiable)
- Real AI summaries from Venice via SIWE wallet auth
- Real OWS policies + session keys created/revoked
- Real dead man's switch firing
- Live dashboard at https://spendos.xyz (auth-gated)
- Real x402 customer payment (paid real USDC, received AI summary)

## Product Vision: Watch, Use, Own

- **Watch** -- Public P&L dashboard. See the agent's revenue, spend, and proposals in real time.
- **Use** -- x402 paid API. Pay $0.01 per query, get AI summaries. No sign-up, no API key. Just pay and use.
- **Own** -- Self-hosted SpendOS. Run your own autonomous agent with your own OWS wallet. Full sovereignty.

## Team
Roman Mondello ([@integrate-your-mind](https://github.com/integrate-your-mind)) + Claude Opus 4.6

## Stack
TypeScript, Express, OWS SDK, x402, Venice AI, OpenClaw (Kimi K2.5), Zerion, viem, Foundry, Railway
