Skip to content

Repository files navigation

AgentVault

A programmable USDC treasury, per-agent budgets, and a kill switch for autonomous AI agents on Solana.

Program on Solana Explorer Live Demo Network License

AI agents are increasingly autonomous — they browse, code, trade, and pay for APIs. AgentVault is the layer that gives an organization control over the money behind those agents: fund a single on-chain USDC treasury, register each agent with a per-task spending rate and role, pay them with verifiable on-chain receipts, and revoke any agent's spending access instantly.

Status: Live on Solana devnet. Deployed and demonstrable end-to-end.


Links

Devnet Program ID 8g5hMx6AwTUFCrKwuaCfDY468qE4bbHiw8BvdiepUJdo
Solana Explorer https://explorer.solana.com/address/8g5hMx6AwTUFCrKwuaCfDY468qE4bbHiw8BvdiepUJdo?cluster=devnet
Live Demo https://frontend-ten-theta-53.vercel.app
IDL endpoint https://frontend-ten-theta-53.vercel.app/api/idl

The program is deployed on devnet only. There is no mainnet deployment.


What it is

AgentVault is an Anchor program plus a TypeScript SDK and CLI for managing money on behalf of AI agents. An admin deploys a USDC vault, registers agents with a per-task spending rate and a role label, and pays them either directly (with a memo) or through a milestone approval flow. Every payment writes an on-chain PaymentRecord PDA — a verifiable receipt — and the admin can deactivate any agent at any time to block its future payouts.


Features

On-chain (Anchor program):

  • USDC treasury vault — a token account owned by the program (create_team, fund_vault). Funds are held by a PDA and only move via program instructions.
  • Register agents with role + per-task rate — up to 15 agents per vault, each with a role label and a rate_per_delivery (add_member).
  • Direct pay with on-chain receipts — pay an active agent directly from the vault with a memo; each payment creates a PaymentRecord PDA (direct_pay).
  • Milestone-gated payments — create a milestone, have the agent submit a deliverable proof URI, then approve-and-pay to release funds (create_milestone, submit_deliverable, approve_and_pay).
  • Kill switch (per-agent) — instantly revoke any agent's spending access. deactivate_member sets the agent to inactive, which blocks its future payouts while preserving its on-chain history. (This is a per-agent revocation — there is no global pause, whitelist, or on-chain time-lock.)

Off-chain (SDK + CLI):

  • TypeScript SDK (@agentvault/sdk) wrapping the program via @coral-xyz/anchor.
  • CLI (agentvault) for creating/funding vaults, registering agents, paying, monitoring, and killing agents from the terminal.
  • Connector framework — real connector classes with beforePay / afterPay lifecycle hooks. Built-ins: ElizaOS, Solana Agent Kit, x402 / Pay.sh, LangChain (and Vercel AI SDK), Webhook, and Custom.

Quickstart

SDK

npm install @agentvault/sdk @coral-xyz/anchor @solana/web3.js
import { AgentVault, X402Connector, WebhookConnector } from "@agentvault/sdk";

const vault = new AgentVault({
  rpc: "https://api.devnet.solana.com",
  wallet: "./deployer.json",
});

// Vault lifecycle
await vault.createVault("My AI Swarm");
await vault.registerAgent(agentPubkey, "Research Agent", 25_000_000); // rate in USDC base units (6 decimals)
await vault.fundVault(1000_000_000); // 1000 USDC

// Optional: add connectors that run on every payment
vault.connectors.use(new X402Connector({ perRequestMax: 25, dailyCap: 100 }));
vault.connectors.use(new WebhookConnector({ webhookUrl: "https://your-server.com/payments" }));

// Pay an agent — connector hooks run, then the on-chain transfer + receipt
const receipt = await vault.pay(agentPubkey, 25_000_000, "GPT-4o API batch");
console.log(receipt.txSignature);

// Check budget, list receipts, revoke access
const budget = await vault.getAgentBudget(agentPubkey);
const receipts = await vault.getReceipts();
await vault.killAgent(agentPubkey); // kill switch — deactivates this agent

CLI

The package installs an agentvault binary.

npm install -g @agentvault/sdk

# Initialize project config
agentvault init --name "My AI Swarm"

# Deploy and fund a vault on devnet
agentvault create-vault
agentvault fund -a 1000

# Register an agent with a per-task budget
agentvault register -a <AGENT_PUBKEY> -r "Research Agent" -l 25

# Pay an agent (writes an on-chain receipt)
agentvault pay -a <AGENT_PUBKEY> -u 25 -m "GPT-4 API batch"

# Monitor
agentvault status
agentvault receipts

# Kill switch — revoke a rogue agent's access
agentvault kill -a <AGENT_PUBKEY>

See packages/agentvault/README.md for full connector usage (ElizaOS plugin, Solana Agent Kit actions, LangChain tools, x402 payAndFetch, webhooks, and custom hooks).


Architecture

Every payment made through the SDK flows through connector hooks before and after the on-chain transfer. Any connector can block a payment in beforePay.

  Agent calls vault.pay(wallet, amount, memo)
          |
          v
  +-- beforePay() hooks -------------------------+
  |  x402: check per-request + daily cap         |
  |  ElizaOS: verify task authorization          |  <-- ANY connector
  |  Custom: your own budget logic               |      can BLOCK
  +----------------------------------------------+
          |  all approved
          v
  +-- ON-CHAIN (Solana devnet) ------------------+
  |  direct_pay instruction                       |
  |  USDC transfer from vault PDA                 |
  |  PaymentRecord PDA created (receipt)          |
  +----------------------------------------------+
          |  success
          v
  +-- afterPay() hooks --------------------------+
  |  Webhook: POST to your URL                    |
  |  Analytics: log to dashboard                  |
  |  x402: update daily spend tracker             |
  +----------------------------------------------+

On-chain account model (all PDAs):

Team ───── Vault (USDC token account, owned by the program)
  │
  ├── Member PDAs        (registered agents: role, rate, active flag, stats)
  ├── Milestone PDAs     (deliverable-gated payments)
  └── PaymentRecord PDAs (on-chain receipts: recipient, amount, memo, timestamp)

Instructions: create_team, add_member, fund_vault, create_milestone, submit_deliverable, approve_and_pay, direct_pay, deactivate_member.

Accounts: Team, Member, Milestone, PaymentRecord.


Connectors

Each connector is a real class with beforePay / afterPay hooks that run on every vault.pay(). Connectors can block payments, enforce budgets, and fire notifications.

Built-in Type What it does
ElizaOSConnector AI framework Exposes CHECK_BUDGET, VAULT_PAY, GET_RECEIPTS actions; can register as an ElizaOS plugin.
SolanaAgentKitConnector AI framework Provides agentVaultPay and checkVaultBudget actions for Solana Agent Kit agents.
X402Connector Payment rail Budget-controlled API payments with per-request and daily-cap enforcement; payAndFetch() wraps HTTP + pay.
LangChainConnector AI framework Exposes a callable tool for LangChain agents; also exports a Vercel AI SDK tool.
WebhookConnector Monitoring POSTs JSON to your URL on every payment; supports a signing secret and minimum-amount filter.
CustomConnector Custom Bring your own beforePay / afterPay logic.
import { AgentVault, CustomConnector } from "@agentvault/sdk";

const vault = new AgentVault({ rpc: "https://api.devnet.solana.com", wallet: "./deployer.json" });

vault.connectors.use(new CustomConnector("my-limiter", "Trade Limiter", {
  beforePay: async (agent, amount, memo) => {
    if (amount > 100_000_000) return { allow: false, reason: "Max $100" };
    return { allow: true };
  },
}));

Project structure

agentvault/
├── programs/agentvault/src/lib.rs   # Anchor program (Rust)
├── tests/agentvault.ts              # Integration tests
├── packages/agentvault/             # SDK + CLI (TypeScript, published as @agentvault/sdk)
│   ├── src/index.ts                 # Public exports
│   ├── src/vault.ts                 # AgentVault class
│   ├── src/connectors.ts            # Connector registry + built-ins
│   ├── src/pda.ts                   # PDA helpers
│   ├── src/types.ts                 # Type definitions
│   ├── src/idl.json                 # Program IDL
│   └── bin/cli.js                   # CLI entrypoint (agentvault)
└── app/frontend/                    # Next.js dashboard + live demo
    ├── app/page.tsx                 # Landing + demo
    ├── app/components/              # Dashboard components
    └── lib/                         # Anchor client

Tech stack

Layer Tech
Smart contract Anchor 0.31.1 (Rust) on Solana
SDK TypeScript, @coral-xyz/anchor, @solana/web3.js, @solana/spl-token
CLI Commander.js, Chalk, Ora
Frontend Next.js, Tailwind CSS
Wallet Phantom (browser), keypair file (CLI)
Token USDC (SPL Token)

Status

Live on Solana devnet. The program is deployed at 8g5hMx6AwTUFCrKwuaCfDY468qE4bbHiw8BvdiepUJdo, the SDK and CLI are functional, and the live demo exercises the full flow (create vault, register agent, fund, pay, kill switch) against devnet. There is no mainnet deployment and no token.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages