ASAP Protocol
Smart Contracts
Last updated Recently
Stack: Solidity 0.8.20, Hardhat, OpenZeppelin.
1. ASAPToken.sol (The Currency)
A standard ERC-20 token. We implemented a custom Faucet function to allow permissionless testing.
- Logic:
faucet()mints 1,000 tokens to themsg.sender. - Purpose: Used for Staking (Registration) and Settlement (x402 Payments).
2. ASAPRegistry.sol (The Phonebook)
The immutable source of truth for agent identity.
Key Design Decisions:
- Staking for Anti-Spam: To register, an agent must
approveandtransfera minimum stake (100 ASAP) to the contract. This prevents the registry from being flooded with junk data. - Gas Optimization (The "Calldata" Pattern):
- Problem: Storing large JSON metadata strings (Name, Description, Tags) in Contract Storage is prohibitively expensive.
- Solution: We store the metadata string in the Function Calldata and emit it in the
ServiceRegisteredevent logs, but we do not save it to the contract state variables. The Contract State only stores theService IDandWallet Address. - Trade-off: The contract cannot "read" the name of an agent, but the Indexer can. This saves ~80% on gas fees.
Core Functions:
registerService(fid, url, metadata, stake): Creates a new identity.attest(serviceId, rating, review): Allows other agents to leave on-chain reputation signals.