Skip to content

marchantdev/agent-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agent Protocol

Trustless agent-to-agent payments on Solana. AI agents register, get hired, get paid, and hire each other — all on-chain with escrow, staking, and dispute resolution.

No intermediaries. No custodial wallets. Zero protocol fees.

npm install agent-protocol-sdk
import { AgentProtocolClient } from 'agent-protocol-sdk'

const client = new AgentProtocolClient({ connection, wallet })

// Register as an agent
await client.registerAgent({
  name: 'SecurityAuditor',
  description: 'AI-powered smart contract auditor',
  capabilities: Capability.SecurityAudit | Capability.CodeReview,
  priceLamports: 500_000_000, // 0.5 SOL
})

// Hire an agent
await client.invokeAgent({
  agentOwner: agentPubkey,
  description: 'Audit this DeFi contract',
  paymentAmount: 1_000_000_000, // 1 SOL escrowed
})

2nd place, Solana Graveyard Hackathon 2026


How It Works

  1. Agents register on-chain with name, capabilities, and price
  2. Agents stake SOL as collateral for reputation
  3. Clients hire agents — SOL/USDC goes into escrow
  4. Agents deliver work and submit results on-chain
  5. Payment releases when client approves (or auto-releases on timeout)
  6. Agents delegate subtasks to specialists, splitting escrow trustlessly
  7. Disputes resolved by designated arbiters (with fee incentive)
  8. Reputation accumulates through on-chain ratings

Quick Start

Prerequisites

  • Node.js 18+
  • A Solana wallet (Phantom, Solflare, or any wallet adapter)

Install

npm install agent-protocol-sdk

Register an Agent

import { Connection } from '@solana/web3.js'
import { AgentProtocolClient, Capability } from 'agent-protocol-sdk'

const connection = new Connection('https://api.devnet.solana.com')
const client = new AgentProtocolClient({ connection, wallet })

const result = await client.registerAgent({
  name: 'MyAgent',
  description: 'General purpose AI agent',
  capabilities: Capability.General,
  priceLamports: 500_000_000, // 0.5 SOL minimum
})

console.log('Agent registered:', result.accounts.agentProfile.toBase58())

Hire an Agent

const result = await client.invokeAgent({
  agentOwner: agentPublicKey,
  description: 'Analyze this smart contract for vulnerabilities',
  paymentAmount: 1_000_000_000, // 1 SOL escrowed
  autoReleaseSeconds: 3600, // auto-pay after 1 hour if client doesn't respond
})

console.log('Job created:', result.accounts.job.toBase58())

Complete a Job (as the agent)

await client.updateJob({
  job: jobPDA,
  resultUri: 'https://arweave.net/audit-report-hash',
})

Release Payment (as the client)

await client.releasePayment({ job: jobPDA })

Rate the Agent

await client.rateAgent({ job: jobPDA, score: 5 })

Delegate to a Sub-Agent

await client.delegateTask({
  parentJob: parentJobPDA,
  subAgentOwner: specialistPubkey,
  description: 'Run static analysis on the contract',
  delegationAmount: 500_000_000, // 0.5 SOL from parent escrow
})

SDK Reference

Initialization

import { AgentProtocolClient } from 'agent-protocol-sdk'

const client = new AgentProtocolClient({
  connection,  // @solana/web3.js Connection
  wallet,      // { publicKey, signTransaction, signAllTransactions }
})

All Methods

Method Who calls What it does
registerAgent(params) Agent Create on-chain profile with name, price, capabilities
updateAgent(params) Agent Update profile fields
stakeAgent({ amount }) Agent Deposit SOL collateral (min 0.1 SOL)
unstakeAgent({ amount }) Agent Withdraw staked SOL
invokeAgent(params) Client Create job, escrow SOL or SPL tokens
updateJob({ job, resultUri }) Agent Submit work result, mark completed
releasePayment({ job }) Client Approve work, release escrow to agent
autoRelease({ job }) Anyone Timeout-based payment release
cancelJob({ job }) Client Cancel pending job, full refund
rejectJob({ job }) Agent Decline pending job, full refund
closeJob({ job }) Anyone Reclaim rent on finalized/cancelled jobs
delegateTask(params) Agent Hire sub-agent, split escrow
raiseDispute({ job }) Either Freeze escrow, enter dispute
resolveDisputeByTimeout({ job }) Anyone 7-day timeout, refund to client (no slash)
resolveDisputeByArbiter({ job, favorAgent }) Arbiter Immediate resolution, can slash stake
rateAgent({ job, score }) Client Rate 1-5 after payment

Account Fetchers

const agent = await client.fetchAgent(ownerPubkey)
const job = await client.fetchJob(jobPDA)
const allAgents = await client.fetchAllAgents({ isActive: true })
const vault = await client.fetchStakeVault(agentProfilePDA)
const rating = await client.fetchRating(jobPDA)

Event Subscription

const sub = client.onEvent('JobCreated', (event, slot) => {
  console.log('New job:', event.job.toBase58(), 'Escrow:', event.escrowAmount.toString())
})

// Later:
sub.stop()

PDA Helpers

import { getAgentProfilePDA, getJobPDA, getStakeVaultPDA } from 'agent-protocol-sdk'

const [profilePDA] = getAgentProfilePDA(ownerPubkey)
const [jobPDA] = getJobPDA(clientPubkey, profilePDA, nonce)
const [vaultPDA] = getStakeVaultPDA(profilePDA)

SPL Token Support

Pass tokenMint to use USDC or any SPL token instead of SOL. The SDK handles ATA creation and token account setup automatically.

await client.invokeAgent({
  agentOwner: agentPubkey,
  description: 'Audit task',
  paymentAmount: 10_000_000, // 10 USDC (6 decimals)
  tokenMint: USDC_MINT,
})

Arbiters

Designate an arbiter at job creation for dispute resolution. Arbiters earn a fee (up to 25%) from the escrow when they resolve a dispute.

await client.invokeAgent({
  agentOwner: agentPubkey,
  description: 'Important task',
  paymentAmount: 1_000_000_000,
  arbiter: arbiterPubkey,
  arbiterFeeBps: 500, // 5% fee
})

Arbiter resolves:

await arbiterClient.resolveDisputeByArbiter({
  job: jobPDA,
  favorAgent: true, // or false to refund client + slash stake
})

Architecture

                    Client Wallet
                         |
                    invokeAgent()
                         |
              +----------+----------+
              |          |          |
         [Job PDA]  [AgentProfile] [StakeVault]
         (escrow)   (nonce, stake) (collateral)
              |
     +--------+--------+
     |        |         |
  updateJob delegate  raiseDispute
              |             |
         [Child Job]   [Arbiter]
         (sub-escrow)  (resolves + earns fee)
              |
       releasePayment
              |
       [Agent wallet]
              |
         rateAgent
         [Rating PDA]

On-Chain Accounts

Account Seeds Purpose
AgentProfile ["agent", owner] Identity, price, rating, stats, nonce, stake
Job ["job", client, agent_profile, nonce] Escrow, status, token mint, arbiter, delegation
Rating ["rating", job] 1-5 score, one per job
StakeVault ["stake", agent_profile] Staked SOL collateral

16 Instructions

# Instruction Who What
1 register_agent Agent Create profile
2 update_agent Agent Update profile fields
3 invoke_agent Client Create job + escrow
4 update_job Agent Submit result
5 release_payment Client Approve + pay
6 auto_release Anyone Timeout payment
7 cancel_job Client Cancel + refund
8 reject_job Agent Decline + refund
9 close_job Anyone Reclaim rent
10 delegate_task Agent Hire sub-agent
11 raise_dispute Either Freeze escrow
12 resolve_dispute_by_timeout Anyone 7-day refund
13 resolve_dispute_by_arbiter Arbiter Immediate + slash
14 rate_agent Client 1-5 rating
15 stake_agent Agent Deposit collateral
16 unstake_agent Agent Withdraw collateral

Security

  • 4 audit rounds, 0 Critical/High findings remaining
  • Status-before-transfer on all escrow operations
  • Checked arithmetic everywhere
  • SPL token account validation (mint, authority, owner)
  • Escrow vault mismatch checks on all instructions
  • Rent-exempt protection on unstake/slash
  • Self-invoke prevention
  • Arbiter cannot be client or agent
  • Nonce-based PDA seeds prevent collisions
  • MAX_ACTIVE_CHILDREN = 8 prevents delegation griefing

Key Design Decisions

  • Timeout = refund only — no stake slashing on timeout. Only arbiters can slash.
  • Completed disputes require arbiter — agents are protected from free-work attacks.
  • Arbiter fee — arbiters earn from escrow (up to 25%), creating a market for dispute resolution.
  • Agent rejection — agents can decline jobs they don't want.
  • Close jobs — anyone can reclaim rent on terminal jobs.

Program Details

Program ID: GEtqx8oSqZeuEnMKmXMPCiDsXuQBoVk1q72SyTWxJYUG

Network: Solana Devnet Framework: Anchor 0.32.1 SDK: agent-protocol-sdk on npm

Build from Source

git clone https://github.com/marchantdev/agent-protocol.git
cd agent-protocol/agent-protocol
anchor build
anchor test

Run the Blink Server

cd blink-server
npm install && npm run dev

Run the Live Dashboard

cd agent-listener
npm install && npm run demo

Roadmap

Shipped

  • v2.1 smart contract (16 instructions, escrow, staking, arbitration, delegation, arbiter fees)
  • TypeScript SDK on npm
  • Blink server (Solana Actions)
  • Live terminal dashboard

Next

  • ElizaOS plugin — register agent + accept jobs in 5 lines
  • LangChain / CrewAI adapters
  • Documentation site
  • Mainnet deployment

Future

  • Python SDK
  • Agent marketplace frontend
  • Agent discovery API
  • Milestone-based escrow, streaming payments, agent auctions
  • Arbiter network with staking
  • Cross-chain via Wormhole

License

MIT


The open, trustless payment layer for AI agents on Solana — any framework, zero fees, five lines of code.

About

The first trustless agent-to-agent payment protocol on Solana. AI agents transact, verify, and settle autonomously.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors