Programmable spending limits for autonomous agents on Solana.
Give agents budgets, not private keys.
AgentGuard Protocol is a Solana-native spending firewall for AI agents. Owners fund a policy vault, define merchant allowlists and token limits, and let an autonomous agent pay only inside those on-chain rules.
The hackathon MVP demonstrates an x402-style paid API flow: the API returns an HTTP 402 challenge, the agent pays through the AgentGuard program, the program checks policy before any token transfer, and the API unlocks paid data only after verifying the on-chain receipt PDA.
- AI agents can pay on Solana without receiving unrestricted wallet access.
- Owners can constrain agent spending with on-chain policy.
- Paid APIs can use AgentGuard receipts as proof of payment.
- Human operators can pause an agent through a Solana Action-style endpoint.
sequenceDiagram
participant Owner
participant Agent
participant API as x402 Demo API
participant Program as AgentGuard Program
participant Merchant
Owner->>Program: initialize_agent + deposit test USDC
Owner->>Program: add_merchant + limits
Agent->>API: GET paid resource
API-->>Agent: HTTP 402 challenge
Agent->>Program: agent_pay(amount, request_hash)
Program->>Program: check authority, allowlist, limits, cap, paused status
Program->>Merchant: SPL token transfer
Program->>Program: create PaymentReceipt PDA
Agent->>API: retry with receipt proof
API->>Program: verify receipt account
API-->>Agent: paid data
- Anchor program with policy vaults and SPL token transfers.
- Owner instructions:
initialize_agentdepositadd_merchantset_policyset_pause
- Agent instruction:
agent_pay
- Policy checks before transfer:
- agent authority
- merchant allowlist
- per-transaction limit
- daily limit
- merchant cap
- paused status
- mint and vault constraints
PaymentReceiptPDA for successful payments.- TypeScript SDK helpers for PDA derivation and transaction construction.
- Express x402-style demo API.
- Agent client that handles the 402 challenge, pays, and retries.
- Next.js dashboard view.
- Solana Action-style pause endpoint.
- Demo runbook and rehearsal checker.
Prerequisites:
- Solana CLI with
solana-test-validator - Anchor 0.32.1
- pnpm
- A local Solana wallet at
~/.config/solana/id.json
Install and build:
pnpm install
anchor buildStart localnet:
solana-test-validator --reset \
--bpf-program 3AfwmYdCAd9LeRdbiKAJuWBcGVQFtCEStbanoU5TW838 \
target/deploy/agentguard_protocol.soIn another terminal, seed the demo:
pnpm --filter @agentguard/x402-demo-api seed
set -a && source .env.demo && set +aStart the paid API:
set -a && source .env.demo && set +a
pnpm --filter @agentguard/x402-demo-api devRun the agent payment flow:
set -a && source .env.demo && set +a
pnpm --filter @agentguard/x402-demo-api agentExpected result:
- The first API request returns an HTTP 402-style challenge.
- The agent submits
agent_pay. - The program creates a
PaymentReceiptPDA. - The API verifies the receipt and returns
paidStatus: 200.
Run an over-limit rejection:
set -a && source .env.demo && set +a
pnpm --filter @agentguard/x402-demo-api agent:over-limitExpected result:
- The program rejects the over-limit payment.
- Vault and merchant balances remain unchanged.
Check the pause Action endpoint:
set -a && source .env.demo && set +a
pnpm --filter @agentguard/web devIn another terminal:
set -a && source .env.demo && set +a
pnpm --filter @agentguard/x402-demo-api check:pause-actionFor the full rehearsal sequence, see docs/DEMO_RUNBOOK.md.
pnpm lint
pnpm -r typecheck
pnpm --filter @agentguard/web build
pnpm test:tsLatest local rehearsal status:
- x402 challenge to
agent_payto paid data: passed. - on-chain receipt verification: passed.
- pause Action transaction generation: passed.
- Anchor tests: 16 passing.
apps/web/ Next.js dashboard and Action endpoint
docs/ Product docs, runbook, and demo script
packages/sdk/ TypeScript PDA and transaction helpers
programs/agentguard-protocol/
Anchor program
services/x402-demo-api/ Demo paid API, agent client, seed scripts
tests/ Anchor TypeScript tests
3AfwmYdCAd9LeRdbiKAJuWBcGVQFtCEStbanoU5TW838
Agent payments need low fees, fast confirmation, cheap receipts, and composable payment surfaces. Solana provides:
- SPL token transfers for USDC-style payments.
- PDAs for policy vaults and receipt addresses.
- Fast settlement for per-request machine payments.
- Actions and Blinks for human override UX.
- Real mainnet custody.
- Full x402 facilitator implementation.
- Natural-language policy parsing.
- Cross-chain execution.
- DeFi strategy automation.
- Enterprise compliance workflow.
- Devnet deployment with real wallet signing.
- USDC integration.
- Facilitator-compatible x402 settlement.
- Dashboard-backed create, deposit, merchant, pause, and receipt views.
- Replay-resistant request metadata and richer receipt verification.
- Multisig or team-owned policy administration.
Apache-2.0