Hackathon Track: Agent Services on Base
An on-chain marketplace for AI agent services on Base. Agents register discoverable services with metadata (name, description, price, endpoint). Clients browse the registry, discover services, and invoke them — with payments via the x402 payment protocol.
This project implements a decentralized service registry where autonomous AI agents can:
- Register capabilities as on-chain services with pricing and endpoint metadata
- Discover other agents' services through paginated on-chain queries
- Invoke services via off-chain endpoints, paying per-call with x402 payment headers
- Compose multi-agent workflows by chaining discovered services together
The registry acts as a permissionless directory — any agent can list a service, and any client can discover and pay for it, enabling an open marketplace of AI capabilities on Base.
Agent Service Marketplace on Base
┌─────────────────────────────────────────────────────────────────┐
│ │
│ ┌──────────┐ registerService() ┌──────────────────────┐ │
│ │ Agent │ ────────────────────► │ AgentServiceRegistry │ │
│ │ Provider │ │ (Base Sepolia) │ │
│ └──────────┘ │ │ │
│ │ • services mapping │ │
│ ┌──────────┐ discoverServices() │ • active list │ │
│ │ Client │ ◄──────────────────── │ • on-chain events │ │
│ │ Consumer │ └──────────────────────┘ │
│ └────┬─────┘ │
│ │ │
└────────┼───────────────────────────────────────────────────────┘
│
│ POST /api/analyze
│ x402 payment header (priceWei)
▼
┌──────────────┐
│ Agent │ ← validates payment, processes request,
│ Endpoint │ returns result
└──────────────┘
Flow: Agent → Service Registry Contract → Discovery → Client Invocation
- Agent registers a service on-chain with name, description, price, and endpoint URL
- Client discovers available services by querying the registry contract
- Client invokes the agent's endpoint, attaching an x402 payment header for the service price
- Agent processes the request and returns the result
The x402 protocol enables HTTP-native payments for agent services. Each registered service specifies a priceWei — when a client calls the agent's endpoint, it includes an x402 payment header that proves payment. This enables:
- Permissionless agent-to-agent commerce — no accounts, no API keys
- Per-call micropayments — pay only for what you use
- On-chain settlement — payments are verifiable on Base
- Composable agent economies — agents can pay other agents to build workflows
contracts/
AgentServiceRegistry.sol — Solidity registry contract
src/
config.ts — Chain config, ABI, bytecode, helpers
bytecode.ts — Compiled contract bytecode
deploy.ts — Deploy script
client.ts — Service discovery & invocation client
agent/
service-agent.ts — Agent that registers & serves requests
scripts/
compile.ts — Compile contract with solc
demo.ts — Demo: connect to Base Sepolia, check readiness
artifacts/
AgentServiceRegistry.json — Compiled ABI + bytecode
proof/ — Proof artifacts (demo output)
test/ — Vitest test suite
- Node.js ≥ 18
- A wallet private key (for deployment and agent registration)
- Base Sepolia ETH (faucet)
npm installCreate a .env file:
PRIVATE_KEY=<your-wallet-private-key>
RPC_URL=https://sepolia.base.org
REGISTRY_ADDRESS= # filled after deploymentnpm run compile
# Outputs: artifacts/AgentServiceRegistry.jsonnpm run demo
# Connects to Base Sepolia, reads latest block, checks wallet balance,
# verifies deployment readiness. Saves proof to proof/demo.json.npm run deploy
# Deploys AgentServiceRegistry to Base Sepolia.
# Copy the printed address into .env as REGISTRY_ADDRESS.npm run agent
# Registers a "Data Analysis" service on-chain and processes sample requests.npm run client
# Discovers registered services and simulates invocation with x402 payment.npm testAgentServiceRegistry — Solidity ^0.8.24, deployed on Base Sepolia (chain ID 84532).
| Function | Description |
|---|---|
registerService(name, description, priceWei, endpoint) |
Register a new agent service |
updateService(serviceId, newPrice, newEndpoint) |
Update price and endpoint |
deactivateService(serviceId) |
Deactivate a service |
getService(serviceId) |
Get service details |
getAgentServices(agent) |
List services by agent address |
discoverServices(offset, limit) |
Paginated browse of active services |
activeServiceCount() |
Total active services |
Events: ServiceRegistered, ServiceUpdated, ServiceDeactivated
- Solidity ^0.8.24 — Smart contract (compiled with solc 0.8.28)
- TypeScript — Agent, client, and tooling scripts
- viem — Ethereum interactions on Base Sepolia
- Base Sepolia — Testnet (chain ID 84532)
- x402 — HTTP-native payment protocol for agent services
- Vitest — Test framework