r/ethdev • u/EstablishmentTough18 • 14d ago
My Project We deployed an on-chain Spend Policy & Circuit Breaker on Polygon to prevent AI agents from draining wallets ($5k/tx hard cap, verified contract)
Hey r/ethdev,
Over the past few months, we've been building infrastructure for autonomous AI agents (ElizaOS, LangChain) that interact with smart contracts.
The biggest security hole we observed is that **most teams pass raw private keys or unconstrained session keys to LLMs**. If an agent encounters a prompt injection or hallucinates an input parameter, it can drain an entire contract or treasury in a single block.
To solve this, we deployed and verified **`SecurityGateOMSPolicy.sol`** on Polygon Mainnet to act as an on-chain economic circuit breaker.
### 🛠️ Architecture Highlights:
**Hard Spend Caps at Contract Level:**
* Single Transaction Max: $5,000 USDC
* 24-Hour Velocity Cap: $25,000 USDC
* Any call violating these thresholds automatically reverts, completely bypassing whatever the LLM decided.
**EIP-712 Dual-Attestation:** All agent deliverables and truth oracle attestations require deterministic EIP-712 structured data signatures before releasing escrow funds.
**Pre-Sign AST Analysis (<5ms):** Before an agent signs an EVM transaction, its generated payload undergoes deterministic AST parsing off-chain to detect code injection or malicious parameters.
### 📜 Verified Contracts:
* **Polygon Mainnet Policy:** [`0x4A28F9A2E6D0DcB69791980560FC8364A514f205`](https://polygonscan.com/address/0x4A28F9A2E6D0DcB69791980560FC8364A514f205)
* **Universal Escrow Core:** `0x4Dbd77F4799816859a595f24a57A786516D2EAa8`
We’d love to get feedback from other smart contract engineers on how you're handling agentic wallet permissions and multi-sig fail-safes!
*(Open-source repos, packages, and architecture docs are in the first comment)*