Sol.College

Full lesson

agentguard-protocol

Programmable spending firewall for autonomous agents on Solana.

What it does

From the project README:

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.
Original
davidweb3-ctrl/agentguard-protocol
SuperStack fork
Blockchains/agentguard-protocol @ e2a0354
Stars
0
Last push (original)
2026-06-05
Languages
TypeScript, JavaScript, Rust
Detected stack
AnchorNext.jsweb3.js
Categories
AI & AgentsDeFi
Licence
Apache-2.0

Architecture

15 source files. By extension: .ts ×12, .tsx ×2, .rs ×1.

Top-level directorySource files
services6
apps4
tests2
migrations1
programs1
packages1

On-chain programs: programs/agentguard-protocol

Dapp: devnet deploy pending

⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/agentguard-protocol/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

davidweb3-ctrl/agentguard-protocol · programs/agentguard-protocol/src/lib.rs L265–288 @ e2a0354 · Apache-2.0 · original
 #[derive(Accounts)]#[instruction(merchant: Pubkey)]pub struct AddMerchant<'info> {    #[account(mut)]    pub owner: Signer<'info>,    #[account(has_one = owner @ ErrorCode::UnauthorizedOwner)]    pub agent_profile: Account<'info, AgentProfile>,    #[account(        init,        payer = owner,        space = 8 + MerchantPolicy::INIT_SPACE,        seeds = [b"merchant", agent_profile.key().as_ref(), merchant.as_ref()],        bump    )]    pub merchant_policy: Account<'info, MerchantPolicy>,    pub system_program: Program<'info, System>,} #[derive(Accounts)]#[instruction(amount: u64, request_hash: [u8; 32])]pub struct AgentPay<'info> {    #[account(mut)]    pub agent_authority: Signer<'info>,
  1. Line 270 pub owner: Signer<'info>,: Requires this account to have signed the transaction.
  2. Line 271 #[account(has_one = owner @ ErrorCode::UnauthorizedOwner)]: Checks that a stored pubkey field matches the passed account.
  3. Line 274 init,: Creates and pays for a new account. Space and payer must be specified.
  4. Line 277 seeds = [b"merchant", agent_profile.key().as_ref(), merchant.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match.
  5. Line 278 bump: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
.npm run buildanchor build
.npm run testanchor test
.npm run lintprettier "**/*.{js,ts,tsx,json,md}" --check
services/x402-demo-apinpm run devpnpm --filter @agentguard/sdk build && tsx src/server.ts
apps/webnpm run devnext dev
apps/webnpm run startnext start
apps/webnpm run buildnext build
apps/webnpm run lintnext lint
packages/sdknpm run buildtsc -p tsconfig.json
.anchor buildcompile programs and generate IDLs
.anchor testlocal validator + test suite
.anchor run testpnpm exec ts-mocha -p ./tsconfig.json -t 1000000 \
.cargo buildRust workspace build
.cargo testRust tests

What you could build from it

Used in lessons