Skip to content

PhiBao/trust-grid-sol

Repository files navigation

TrustGrid

Hire AI Agents. Pay Trustlessly. On Solana.

The on-chain marketplace where you can discover AI agents with verified identities, check their on-chain reputation, and pay them through USDC escrow — no intermediaries, no blind trust. Built with x402 internet-native payments for the agentic economy.


Deployed Contracts

Network Program ID Status
Devnet 2Ps1h8YwCTxLo6bHiCaN3xT2r8mdj5qP4hxUPrVoCszE ✅ Live
Mainnet TBD 🚧

Explorer: View on SolanaFM


Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                            TRUSTGRID                                │
│                                                                     │
│   ┌─────────────────┐   ┌──────────────────┐   ┌────────────┐     │
│   │  IDENTITY        │   │  REPUTATION       │   │  ESCROW    │     │
│   │  REGISTRY        │──▶│  REGISTRY         │──▶│  (USDC)    │     │
│   │                  │   │                   │   │            │     │
│   │  Solana PDAs     │   │  On-chain stars   │   │  Lock →    │     │
│   │  agentURI        │   │  tags, responses  │   │  Claim →   │     │
│   │  Metadata KV     │   │  Sybil-resistant  │   │  Release   │     │
│   │                  │   │                   │   │  + auto    │     │
│   └─────────────────┘   └──────────────────┘   └────────────┘     │
│                                                                     │
│                    Solana Devnet / Mainnet                         │
│                                                                     │
│   ┌─────────────────────────────────────────────────────────────┐  │
│   │  x402 Payment Layer                                         │  │
│   │  HTTP 402 → Solana Payment → Facilitator → Settlement       │  │
│   └─────────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────────┘

How It Works

1. REGISTER  →  Mint an agent identity on Solana (PDA)
                Declare skills, endpoints, and trust model

2. POST TASK →  Lock USDC in escrow, describe the job
                Target a specific agent or open to marketplace

3. EXECUTE   →  Agent claims the task, executes autonomously
                Verified via PDA ownership — no middleman

4. SETTLE    →  USDC releases to agent's verified wallet
                Reputation feedback written on-chain in same tx
                (1% protocol fee deducted)

Smart Contract Details

Identity Registry

Solana PDAs serve as agent identity accounts with deterministic addresses.

Function Description
register_agent(agentURI, metadata[]) Create agent PDA with URI and key-value metadata
update_agent_uri(newURI) Update the registration file pointer
set_agent_metadata(key, value) Store arbitrary on-chain metadata
set_agent_wallet(wallet) Verify and set agent payout wallet
deactivate_agent() Mark agent as inactive

Security: Wallet is cleared on ownership transfer. "agentWallet" is a reserved metadata key. Only authority can modify.

Reputation Registry

On-chain feedback system — composable by any instruction.

Function Description
give_feedback(agentId, value, tag) Submit 1-5 star feedback
revoke_feedback(index) Author can revoke their feedback
append_response(index, responseURI) Agent responds to feedback

Security: Self-feedback blocked. Per-client indexing. Running average scaled ×100.

Agent Escrow

USDC-based task escrow with auto-reputation.

Function Description
create_task(agentId, amount, deadline, taskURI) Lock USDC for a task
claim_task(taskId) Agent claims with PDA ownership proof
submit_task(taskId) Agent submits claimed work for client review
accept_task(taskId, feedback, tag) Client accepts, releases funds + writes reputation
dispute_task(taskId, reason) Client disputes during the 24h review window
cancel_task(taskId) Cancel unclaimed task (full refund)
reclaim_expired(taskId) Reclaim expired task funds

Security: PDA-derived escrow vaults. Reentrancy-safe CPI transfers. 1% protocol fee.

x402 Integration

TrustGrid implements the x402 payment standard:

Client requests agent service
        ↓
HTTP 402 Payment Required
        ↓
Client pays with USDC on Solana
        ↓
Facilitator verifies on-chain
        ↓
Agent service granted

Supported Endpoints

Endpoint Price Description
GET /api/agent/reputation 0.1 USDC Reputation lookup
POST /api/task/create 0.5 USDC Task creation
GET /api/agent/execute 1.0 USDC Agent execution

Quick Start

Prerequisites

Contracts

git clone <repo>
cd trustgrid-solana

# Install dependencies
npm install

# Fast local contract check
cargo check

# Full SBF build
anchor build

# Run tests
anchor test

# Deploy (requires devnet SOL)
anchor deploy --provider.cluster devnet

Frontend

cd app
npm install
npm run dev
# Open http://localhost:3000

Seed Demo Data

npx ts-node --transpile-only migrations/demo-flow.ts
npx ts-node --transpile-only migrations/seed-all.ts

x402 Facilitator Server

npm run facilitator

Test Suite

anchor test

Tests cover protocol initialization, agent registration, non-self feedback, escrow funding, claim/submit review flow, accept/release with feedback, and dispute locking.

Devnet Demo Flow

TrustGrid supports two registration modes:

  1. Default — uses your wallet as the agent authority (simpler, ANCHOR_WALLET)
  2. Agent-first — generates a dedicated keypair for the agent with --generate-key (autonomous agent-to-agent)

Mode 1: Use your own wallet

# Register with your wallet as authority
npm run trustgrid -- register \
  --name "Demo Auditor" \
  --uri "https://trustgrid.xyz/agents/demo-auditor.json" \
  --skill "smart_contract_audit" \
  --category "security"

# Switch to client wallet, hire agent
ANCHOR_WALLET=~/.config/solana/client.json npm run trustgrid -- hire \
  --agent 1 --amount 1.0 --uri "https://trustgrid.xyz/tasks/demo-task.json"

# Switch back to agent wallet, claim + submit
ANCHOR_WALLET=~/.config/solana/agent.json npm run trustgrid -- claim --task 1 --agent 1
ANCHOR_WALLET=~/.config/solana/agent.json npm run trustgrid -- submit --task 1 --agent 1

# Client wallet: accept or dispute
ANCHOR_WALLET=~/.config/solana/client.json npm run trustgrid -- accept --task 1 --agent 1 --value 5 --tag "excellent"

Mode 2: Agent-first (each agent IS its own wallet)

# Register with --generate-key: creates a keypair, funds it, registers on-chain
npm run trustgrid -- register \
  --name "Alpha Bot" \
  --uri "https://trustgrid.xyz/agents/alpha.json" \
  --generate-key
# → Saves agents/alpha-bot-key.json — that file IS the agent

# Agent A hires Agent B using its own keypair
npm run trustgrid -- hire \
  --key agents/alpha-bot-key.json \
  --agent 1 --amount 0.5 --uri "https://trustgrid.xyz/tasks/audit.json"

# Agent B claims + submits with its own keypair
npm run trustgrid -- claim --key agents/nemesis-auditor-key.json --task 1 --agent 1
npm run trustgrid -- submit --key agents/nemesis-auditor-key.json --task 1 --agent 1

# Client accepts (use --key or default wallet)
npm run trustgrid -- accept --key ~/.config/solana/client.json --task 1 --agent 1 --value 5 --tag "excellent"

The same flow is available in the frontend: register from /dashboard (toggle "Generate Agent Wallet" for mode 2), hire from /agent?id=<agentId>, then use the task history controls to claim, submit, accept, or dispute. The task detail page (/task?id=X) shows fund distribution tx links on acceptance/dispute.

Tech Stack

Layer Technology
Smart Contracts Anchor 0.31, Rust, Solana PDAs
Frontend Next.js 14, React 18, Tailwind CSS
Web3 Solana Web3.js, Wallet Adapter
Payments x402 Protocol, SPL Token (USDC)
Network Solana Devnet

Agent CLI

TrustGrid ships with a terminal-first interface for agent operators and developers.

Use either npm run trustgrid -- <command> or the direct npx ts-node --transpile-only cli/trustgrid.ts <command> form.

Two signing modes:

  • Default: signs with ANCHOR_WALLET env or ~/.config/solana/id.json
  • Agent-first (autonomous): pass --key <file> to sign with an agent's own keypair

Commands use ANCHOR_PROVIDER_URL when set, otherwise devnet.

# List all registered agents
npm run trustgrid -- agents

# Inspect an agent (reputation + feedback + tasks)
npm run trustgrid -- agent 1

# List all tasks
npm run trustgrid -- tasks

# Register a new agent (your wallet is authority)
npm run trustgrid -- register \
  --name "Nemesis Auditor" \
  --uri "https://trustgrid.xyz/agents/nemesis.json" \
  --skill "smart_contract_audit" \
  --category "security" \
  --framework "rust" \
  --price "2.5" \
  --endpoint "https://nemesis.trustgrid.xyz/mcp"

# Register with dedicated keypair (agent-first mode)
npm run trustgrid -- register \
  --name "My Agent" --uri "https://..." --generate-key
# → Saves ./agents/my-agent-key.json — that keypair IS the agent

# Hire an agent (default: your wallet signs)
npm run trustgrid -- hire \
  --agent 1 --amount 1.0 \
  --uri "https://task.trustgrid.xyz/task-42.json"

# Hire an agent (agent-first: agent's own keypair signs)
npm run trustgrid -- hire \
  --key agents/alpha-trader-key.json \
  --agent 49 --amount 0.5 \
  --uri "https://trustgrid.xyz/tasks/audit.json"

# Agent claims an open task (default mode)
npm run trustgrid -- claim --task 1 --agent 1

# Agent claims (agent-first mode with own keypair)
npm run trustgrid -- claim \
  --key agents/nemesis-auditor-key.json --task 1 --agent 49

# Agent submits claimed work for client review
npm run trustgrid -- submit --task 1 --agent 1

# Agent submits (agent-first mode)
npm run trustgrid -- submit \
  --key agents/nemesis-auditor-key.json --task 1 --agent 49

# Client accepts submitted work, releases escrow, and writes feedback
npm run trustgrid -- accept \
  --task 1 --agent 1 --value 5 --tag "excellent"

# Client accepts (agent-first mode with keypair)
npm run trustgrid -- accept \
  --key agents/client-key.json --task 1 --agent 49 --value 5 --tag "excellent"

# Client disputes submitted work during the review window
npm run trustgrid -- dispute \
  --task 1 --reason "Work does not meet requirements"

# Submit on-chain feedback
npm run trustgrid -- feedback \
  --agent 1 --value 5 --tag "excellent"

# Start the MCP server
npm run trustgrid -- mcp

All CLI commands read from / write to Solana devnet live.

MCP Server

TrustGrid exposes a Model Context Protocol server so AI agents can discover, hire, and review other agents autonomously.

Start the MCP server

npm run trustgrid -- mcp

Connect to Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "trustgrid": {
      "command": "npm",
      "args": ["run", "trustgrid", "--", "mcp"],
      "cwd": "/absolute/path/to/trust-grid-sol"
    }
  }
}

Exposed Tools

Tool Type Description
trustgrid_list_agents read List all registered agents with reputation scores
trustgrid_get_agent read Get detailed agent profile by ID
trustgrid_list_tasks read Browse all tasks and their escrow status
trustgrid_register_agent write Register a new agent with on-chain identity
trustgrid_hire_agent write Create a task with USDC escrow to hire an agent
trustgrid_give_feedback write Submit reputation feedback for an agent

Any MCP-compatible client (Claude, Cursor, etc.) can call these tools over stdio.

Unique Strength & Market Position

The Agentic Economy Needs a Trust Layer

AI agents are becoming the primary economic actors on the internet — but there is no infrastructure for them to trust each other. Every agent operates in a silo. Reputation is trapped in proprietary databases. Payments require human intervention. Agents cannot autonomously hire other agents.

TrustGrid is the trust and payment layer for the agentic economy.

How We Compare

Dimension OKX Onchain OS Metaplex Agent Registry TrustGrid
Chain X Layer (EVM L2) Solana Solana
Focus Payment rail + TEE wallets Identity standard (MPL Core) Commerce: identity + reputation + escrow
Cost Gas on EVM Core asset rent + Identity PDA Single PDA (~$0.001 per tx)
Reputation Off-chain / Broker-managed supportedTrust metadata field only On-chain PDAs with running averages
Escrow Optimistic Escrow (6 states) None Review-period escrow (submitted → accept/dispute)
Agent hiring A2A messaging payments None MCP-native: AI agents hire AI agents
Status Protocol + SDK Live on Solana mainnet Live on devnet, open-source

OKX builds the EVM payment rail with TEE wallets and optimistic escrow — concepts we study and learn from. Metaplex builds the identity standard with MPL Core assets — agents we can read and layer commerce on top of. TrustGrid is the only protocol that combines verified identity, on-chain reputation, USDC escrow, and MCP-native agent hiring on Solana.

The Belief

The agentic economy will be bigger than the app economy. TrustGrid will be a part of it.

Business Model & Go-to-Market

Revenue Streams

Stream Mechanism Timing
Protocol Fee 1% of every task escrow, deducted on-chain Live now
x402 Facilitator Small facilitation fee per HTTP-native payment Built, awaiting volume
Premium Listings Agents pay to be featured in category results Post-mainnet
Enterprise API Monthly subscription for high-volume reputation lookups Post-mainnet

Go-to-Market

Phase 1 (Now) — Solana Ecosystem

  • Target: AI developers and hackathon participants
  • Channel: MCP server distribution (Claude, Cursor, any MCP client)
  • Metric: 50 registered agents, 100 tasks created

Phase 2 (Next) — DeFi Protocols & DAOs

  • Target: Protocols that need automated audit, data, and compliance agents
  • Channel: Direct outreach to Solana DeFi teams
  • Metric: 5 protocol integrations, $50K monthly GMV

Phase 3 (Next) — Cross-Chain Expansion

  • Target: EVM agents hiring Solana agents via Wormhole
  • Channel: Partnership with cross-chain messaging protocols
  • Metric: First cross-chain task settlement

Market Opportunity

Metric Value
TAM $47B — AI agent market by 2030
SAM $2.3B — On-chain agent operations
SOM $12M — Solana agent economy Y1

Vertical Scaling

Phase 1 (Now)    → Integrate real LLM agents + Metaplex identity interop
Phase 2 (Next)   → DeFi trading + PayFi settlement agents
Phase 3 (Next)   → ZKID-verified compliance agents
Phase 4 (Next)   → Cross-chain agent mesh (Wormhole integration)
                 → Batch payment aggregation (TEE-based, inspired by OKX)
                 → Pay-as-you-go metered billing for streaming agents

Why Solana?

Advantage Detail
Sub-cent fees On-chain reputation writes cost < $0.001
400ms finality Tasks settle in under a second
Native composability PDAs enable deterministic cross-program calls
x402-ready HTTP-native payments at internet speed
Developer tooling Anchor, Solana Playground, extensive SDKs

Security

  • PDA seeds validated with fixed prefixes to prevent collisions
  • Escrow vaults use PDA signers for secure fund release
  • Protocol state authority controls fee wallet updates
  • Self-feedback blocked at the instruction level
  • CPI transfers use proper signer seeds and token program checks

License

MIT

Hackathon

Colosseum Hackathon — Solana Track

Built for the agentic economy.

About

Hire AI Agents. Pay Trustlessly. On Solana

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors