1-
21# Policy-Governed Agent Payments (PGAP)
32
43## Overview
@@ -36,7 +35,6 @@ Existing systems rely on off-chain trust or agent self-restraint, which does not
3635
3736## High-Level Architecture
3837
39-
4038```
4139User / Service Request
4240 ↓
@@ -55,7 +53,31 @@ TreasuryWithPolicy (on-chain)
5553- executes or reverts
5654 ↓
5755USDC (native Arc settlement)
56+ ```
57+
58+ ---
59+
60+ ## Demo Overview
61+
62+ This demo intentionally uses ** small policy limits ($1 per transaction)** to make enforcement behavior immediately visible on testnet without exhausting faucet-limited USDC.
63+
64+ The demo showcases five scenarios executed against the same on-chain Treasury:
65+
66+ 1 . ** Valid Payment** — Agent proposes a compliant payment → executed on-chain
67+ 2 . ** AI Refusal** — Agent refuses to propose an over-limit payment
68+ 3 . ** Cooldown Enforcement** — Treasury rejects rapid repeated payments
69+ 4 . ** Unauthorized Recipient** — Treasury blocks payments to non-allowlisted addresses
70+ 5 . ** Replay Protection** — Treasury rejects reused nonces deterministically
5871
72+ These scenarios demonstrate ** defense in depth** :
73+ - AI performs bounded reasoning
74+ - Smart contracts remain the final authority
75+
76+ ** Run the demo:**
77+ ``` bash
78+ cd agent
79+ npm install
80+ npm run demo
5981```
6082
6183---
@@ -80,13 +102,13 @@ USDC (native Arc settlement)
80102
81103** Purpose:** Act as a firewall between AI intent and real funds.
82104
83- ** Enforced Invariants (examples) :**
105+ ** Enforced Invariants:**
84106- Per-transaction spending limit
85107- Daily spending cap
86- - Cooldown between payments
87108- Recipient allowlist
88109- Replay protection via nonces
89110- Global pause for emergencies
111+ - Cooldown between payments (rate-limits agent execution to reduce blast radius)
90112
91113** Critical Property:** The treasury does not care how the intent was generated—only whether it satisfies policy.
92114
@@ -118,7 +140,7 @@ This preserves a strict trust boundary.
118140
119141** Responsibilities:**
120142- Accept structured intent from Gemini
121- - Optionally call ` validateIntent() `
143+ - Optionally call ` validateIntent() ` for pre-checks
122144- Submit ` executePayment() ` transaction
123145- Log transaction hash and result
124146
@@ -129,7 +151,7 @@ The backend is stateless and replaceable.
129151## Why This Architecture Is Trustless
130152
131153| Layer | Trust Model |
132- | ------| -------------|
154+ | ------- | -------------|
133155| Gemini AI | Untrusted proposer |
134156| Backend | Untrusted relayer |
135157| Smart Contracts | Fully trusted enforcement |
@@ -142,6 +164,17 @@ Even if:
142164
143165➡️ ** Funds remain safe.**
144166
167+ ### Security Guarantees
168+
169+ Even with high policy limits, the system maintains bounded risk:
170+ - ** Per-agent isolation:** One compromised agent can't drain another's budget
171+ - ** Worst-case loss:** Limited to (perTxLimit × transactions per day)
172+ - ** Immediate revocation:** Owner can pause or revoke agent instantly
173+ - ** Audit trail:** All payments recorded on-chain for forensic analysis
174+ - ** No AI custody:** Agents never hold funds, only propose intents
175+
176+ This architecture enables autonomous operations while maintaining deterministic safety bounds.
177+
145178---
146179
147180## Why Arc + Native USDC
@@ -165,8 +198,8 @@ PGAP was deployed in two configurations during development for clear and intenti
165198This deployment represents the intended production architecture using native Arc USDC.
166199
167200** Contracts:**
168- - AgentRegistry: ` 0xa2225ce1F9e764bF11a57d3E8dea0492487562Ea `
169- - TreasuryWithPolicy: ` 0x9fB95CE21352d7FAB5A8A79aEB1E30B76F11B034 `
201+ - AgentRegistry: ` 0xa2225ce1F9e764bF11a57d3E8dea0492487562Ea `
202+ - TreasuryWithPolicy: ` 0x9fB95CE21352d7FAB5A8A79aEB1E30B76F11B034 `
170203
171204** Properties:**
172205- Uses native Arc Testnet USDC
@@ -182,9 +215,9 @@ A successful on-chain payment was executed from this treasury using Arc Testnet
182215This deployment exists solely to enable exhaustive testing without faucet constraints.
183216
184217** Contracts:**
185- - AgentRegistry: ` 0x853b31b0541059c72a76deeB23eA4414AdB42B58 `
186- - TreasuryWithPolicy: ` 0x2c90738D80C19dDe2094B5E58b4dC06202fa1243 `
187- - MockUSDC: ` 0xBa9c42df8e2b800902A5191971634825F958DA04 `
218+ - AgentRegistry: ` 0x853b31b0541059c72a76deeB23eA4414AdB42B58 `
219+ - TreasuryWithPolicy: ` 0x2c90738D80C19dDe2094B5E58b4dC06202fa1243 `
220+ - MockUSDC: ` 0xBa9c42df8e2b800902A5191971634825F958DA04 `
188221
189222** Rationale:**
190223- Arc Testnet USDC is faucet-limited
@@ -195,7 +228,6 @@ This separation ensures testing rigor without weakening the real deployment.
195228
196229---
197230
198-
199231## Verified Arc USDC Transaction
200232
201233PGAP successfully executed a live payment using ** native Arc Testnet USDC** , fully governed by on-chain policy.
@@ -206,27 +238,166 @@ PGAP successfully executed a live payment using **native Arc Testnet USDC**, ful
206238- ** Relayer:** ` 0x8eCaDD0bA353048e9c92A5a2be341ce902250C41 `
207239- ** Amount:** 1 USDC
208240- ** Transaction Hash:**
209- ` 0x735a3abf24866c376d8150c7698d001d3f36183ee991c77633cf08c24c818185 `
241+ ` 0x735a3abf24866c376d8150c7698d001d3f36183ee991c77633cf08c24c818185 `
242+ - ** Explorer:** [ View on Arcscan] ( https://testnet.arcscan.app/tx/0x735a3abf24866c376d8150c7698d001d3f36183ee991c77633cf08c24c818185?tab=index )
210243
211244This transaction demonstrates that:
212- - AI proposed the payment
213- - Smart contracts enforced all limits
214- - Settlement occurred directly in Arc USDC
245+ - AI proposed the payment
246+ - Smart contracts enforced all limits
247+ - Settlement occurred directly in Arc USDC
248+
249+ ---
250+
251+ ## Configurable Policy Limits (Production)
252+
253+ The $1 per-transaction limit used in the demo is intentionally conservative for clarity and testnet constraints.
254+
255+ In production, organizations configure policy thresholds based on risk tolerance—** without changing contract logic** .
256+
257+ | Organization Type | Per-Tx Limit | Daily Limit | Example Use Case |
258+ | -------------------| -------------| -------------| ------------------|
259+ | Small Business | $100 | $500 | API calls, stock assets |
260+ | Mid-Size Company | $1,000 | $10,000 | Data subscriptions |
261+ | Enterprise | $10,000+ | $100,000+ | Real-time research feeds |
262+
263+ Only configuration values change via ` updatePolicy() ` .
264+ The enforcement engine remains identical.
265+
266+ ** Example:**
267+ ``` solidity
268+ treasury.updatePolicy(
269+ 100_000_000_000, // $100,000 per-tx
270+ 500_000_000_000, // $500,000 daily
271+ 1 hours // cooldown
272+ );
273+ ```
274+
275+ ---
276+
277+ ## Service Integration Patterns
278+
279+ ### Pattern 1: Direct API Integration
280+ ```
281+ Agent queries API pricing endpoint
282+ API returns: { "service": "weather", "cost": 0.50 }
283+ Agent proposes payment intent
284+ Treasury validates and executes
285+ ```
286+
287+ ### Pattern 2: Invoice-Based
288+ ```
289+ Service emails invoice
290+ Frontend OCR extracts amount
291+ Human reviews and approves
292+ Agent executes payment
293+ ```
294+
295+ ### Pattern 3: Subscription Management
296+ ```
297+ Monthly subscription: $49
298+ Agent auto-pays on due date
299+ Treasury enforces limits
300+ Human monitors via dashboard
301+ ```
215302
303+ ---
304+
305+ ## Why This Architecture Scales
216306
217- ## Note on USDC Availability
307+ - ✅ ** Configurable limits** — Adjust risk tolerance without code changes
308+ - ✅ ** Multi-agent support** — Each agent tracked independently
309+ - ✅ ** Composable policies** — Per-tx + daily + cooldown + allowlist
310+ - ✅ ** Deterministic enforcement** — No AI can bypass on-chain rules
311+ - ✅ ** Audit trail** — All payments recorded on-chain
312+ - ✅ ** Emergency controls** — Pause mechanism for incidents
218313
219- Arc Testnet USDC is currently faucet-limited.
220- A request has been submitted to Circle for additional testnet USDC to enable higher-volume and multi-payment demonstrations.
314+ The system is production-ready; deployment specifics depend on organizational requirements.
221315
222316---
223317
224- ## Design Intent
318+ ## Future Extensions
319+
320+ Future iterations may include:
321+ - Frontend dashboards for policy configuration
322+ - Invoice/receipt parsing to pre-fill intents
323+ - Approval queues for over-limit payments
324+ - Reputation-based dynamic policy adjustments
325+
326+ These features extend the system but do not alter its core security model.
327+
328+ ---
329+
330+ ## Quick Start
331+
332+ ### Prerequisites
333+ - Foundry installed
334+ - Node.js v18+
335+ - Arc Sepolia testnet access
336+
337+ ### Installation
338+
339+ ``` bash
340+ git clone git@github.com:tr-Kalyan/policy-governed-agent.git
341+ cd policy-governed-agent
342+
343+ # Install contract dependencies
344+ forge install
345+
346+ # Install agent dependencies
347+ cd agent
348+ npm install
349+ ```
350+
351+ ### Run Demo
352+
353+ ``` bash
354+ cd agent
355+ npm run demo
356+ ```
357+
358+ ---
225359
226- Maintaining both deployments is a deliberate engineering decision:
360+ ## Testing
361+
362+ ``` bash
363+ # Smart contract tests
364+ forge test -vvv
365+
366+ # Agent integration tests
367+ cd agent
368+ npm test
369+ ```
370+
371+ ---
372+
373+ ## Built With
374+
375+ - [ Solidity ^0.8.26] ( https://soliditylang.org/ )
376+ - [ Foundry] ( https://book.getfoundry.sh/ )
377+ - [ OpenZeppelin Contracts] ( https://docs.openzeppelin.com/contracts/ )
378+ - [ Arc Network] ( https://arc.gateway.fm/ )
379+ - [ Circle USDC] ( https://www.circle.com/usdc )
380+ - [ Google Gemini] ( https://ai.google.dev/ )
381+
382+ ---
383+
384+ ## Hackathon Tracks
385+
386+ This project competes in:
387+ - 🏆 ** Best Trustless AI Agent** (Circle + Arc)
388+
389+ ---
390+
391+ ## License
392+
393+ MIT
394+
395+ ---
227396
228- - Native USDC deployment proves correctness and settlement integrity
229- - MockUSDC deployment proves safety under adversarial conditions
397+ ## Acknowledgments
230398
231- This mirrors real-world protocol development with production contracts and isolated test environments.
399+ Built at [ @ lablabai ] ( https://lablab.ai ) 's Agentic Commerce on Arc Hackathon
232400
401+ Powered by:
402+ - [ @BuildOnCircle ] ( https://twitter.com/BuildOnCircle )
403+ - [ @GoogleAI ] ( https://twitter.com/GoogleAI )
0 commit comments