The Infrastructure Layer for the Autonomous Agent Economy.
ASAP is a decentralized protocol designed to solve the "Cold Start" problem for AI Agents. It provides the necessary infrastructure for agents to discover each other, establish trust through on-chain reputation, and exchange services using the x402 (Payment Required) standard without human intervention.
This repository contains the core protocol implementation, including the smart contracts, indexing service, frontend interface, and developer SDK.
The protocol is composed of four distinct, interoperable layers. This monorepo is structured to house all core components:
| Component | Directory | Description | Stack |
|---|---|---|---|
| Registry Layer | /contracts |
The immutable source of truth. Handles agent registration, staking, and attestation logic. | Solidity, Hardhat, Base Sepolia |
| Data Layer | /indexer |
An off-chain projection of the blockchain state. Listens to events and serves high-speed queries via API. | Node.js, Viem, SQLite |
| Interface Layer | /frontend |
A reference dApp for humans to explore the registry, manage identity, and test endpoint connectivity. | React, Vite, Wagmi, Tailwind |
| Integration Layer | /sdk |
A TypeScript library for developers to integrate ASAP discovery and verification into their agents. | TypeScript, Viem |
- Provider Registration: An AI Agent (or developer) stakes
ASAPtokens to register their endpoint URL on the Smart Contract. - Indexing: The Indexer detects the
ServiceRegisteredevent, fetches the metadata, and updates the local database. - Discovery: A Consumer Agent queries the Indexer (via SDK) to find services matching specific tags or reputation scores.
- The Handshake (x402):
- The Consumer hits the Provider's endpoint.
- The Provider returns
402 Payment Required. - The Consumer pays the required tokens on-chain.
- The Provider verifies the transaction and grants access.
ASAP implements a standardized flow for machine-to-machine commerce, reviving the reserved HTTP 402 status code.
sequenceDiagram
participant Consumer as Agent (Consumer)
participant Provider as Service (Oracle)
participant Chain as Blockchain (Base)
Consumer->>Provider: GET /api/data
Provider-->>Consumer: 402 Payment Required { recipient, amount, token }
Note over Consumer: Agent parses requirements & signs Tx
Consumer->>Chain: Transfer Tokens (ERC-20)
Chain-->>Consumer: Transaction Hash (Proof)
Consumer->>Provider: GET /api/data + Header: "Authorization: Bearer <TxHash>"
Note over Provider: Verifies Tx on-chain via RPC
Provider-->>Consumer: 200 OK { payload }
To run the full protocol stack locally, follow this deployment order.
- Node.js v18+
- npm or yarn
- MetaMask (configured for Ethereum Sepolia or Base Sepolia)
- An RPC URL (e.g., Alchemy or Public Node)
The foundation must be laid first.
cd contracts
npm install
# Create .env with PRIVATE_KEY
npx hardhat run scripts/deploy.ts --network sepoliaAction: Copy the deployed Registry and Token addresses.
The indexer needs to know where to look.
cd indexer
npm install
# Edit src/index.ts: Update REGISTRY_ADDRESS with your deployed address
npx ts-node src/index.tsKeep this terminal running. It will log events as they happen on-chain.
The user interface for interaction.
cd frontend
npm install
# Create .env: Add VITE_REGISTRY_ADDRESS and VITE_TOKEN_ADDRESS
npm run devAccess the dApp at http://localhost:5173.
While this repository hosts the infrastructure, we have built reference implementations to demonstrate the protocol in action.
Repository: github.com/AtharvRG/asap-bot
A Python-based autonomous agent that:
- Queries the ASAP Indexer to find specific services.
- Autonomously negotiates the x402 handshake.
- Signs and broadcasts blockchain transactions without human input.
- Consumes the paid data.
Repository: github.com/AtharvRG/asap-oracle
A serverless function (deployed on Netlify) that:
- Acts as a paid API endpoint.
- Strictly enforces the 402 Payment Required status.
- Performs cryptographic verification of payment proofs (Transaction Hashes) before releasing data.
The registry uses a staking mechanism to prevent spam. Service providers must lock ASAP tokens to register. Additionally, the protocol supports on-chain attestations, allowing the Farcaster social graph to vouch for the quality of specific agents, creating a Web of Trust.
Events emitted by the ASAPRegistry contract are intentionally minimal (containing only IDs and pointers) to reduce gas costs. The Indexer is responsible for "hydrating" this data by performing secondary readContract calls to fetch full metadata strings, shifting the computational burden off-chain.
The frontend implements aggressive cache invalidation strategies using TanStack Query. This ensures that UI elements (like token balances and access states) update immediately after a block is mined, handling the asynchronous nature of blockchain state changes gracefully.
This project is licensed under the MIT License.
