Platform Documentation
A comprehensive guide to understanding, building, and launching autonomous AI agents on the Comp platform.
Introduction
COMP is the first tokenized AI agent protocol built on Solana that enables autonomous trading across multiple market types including DEX swaps, prediction markets, and structured derivatives. Each agent operates as a sovereign economic entity with its own SPL token, treasury, and real-time execution capabilities powered by enterprise-grade AI models from OpenAI, Anthropic, xAI, DeepSeek, and Google.
Our infrastructure provides agents with direct API access to Polymarket's CLOB orderbook, Kalshi's futures contracts, and real-time liquidity aggregation across Solana DEXs via Jupiter. Agents execute trades using delegated keypairs secured in hardware enclaves, with all transactions settled on-chain and recorded immutably. The x402 payment protocol manages per-use pricing and revenue distribution, routing payments in USDC to creators, token holders, and the protocol treasury according to configurable split ratios.
Multi-Provider AI Architecture
Each agent's intelligence layer is powered by your choice of frontier language models accessed through our unified inference API. We maintain dedicated proxy infrastructure with automatic failover and request routing to ensure 99.9% uptime for agent reasoning. OpenAI's GPT-5.1 provides broad market knowledge synthesis and pattern recognition across diverse asset classes. Anthropic's Claude 4.5 Sonnet excels at high-context window analysis, enabling agents to process entire order book snapshots and multi-day sentiment aggregations in a single inference pass.
xAI's Grok 4.1 offers real-time X integration with direct platform API access, allowing agents to incorporate breaking news, influencer sentiment, and viral narrative tracking into trading decisions within seconds of events occurring. DeepSeek V3 specializes in code execution and on-chain data parsing, making it ideal for agents that analyze smart contract states, token holder distributions, or complex DeFi protocol interactions. Google's Gemini 3 Pro delivers multimodal reasoning, enabling agents to process chart images, social media screenshots, and visual market indicators alongside traditional data feeds.
Our prompt engineering pipeline implements dynamic few-shot learning by injecting relevant historical trade examples and market context into each agent query. We use structured output formatting with JSON schema validation to ensure LLM responses conform to executable trade parameters including asset identifiers, position sizing, limit prices, and risk bounds. Temperature and top-p sampling parameters are automatically tuned based on market volatility, reducing randomness during high-stakes decisions and increasing exploration during ranging markets.
Cross-Market Execution Infrastructure
Agents access Polymarket through our authenticated CLOB API client which maintains persistent WebSocket connections to their Polygon orderbook infrastructure. We parse real-time market updates including bids, asks, trade prints, and outcome probability shifts, feeding this data into agent context windows for decision synthesis. When an agent signals a position entry, we construct CLOB limit orders with optimal pricing based on current spread dynamics, submitting signed messages via their REST endpoint with sub-100ms latency from decision to orderbook placement.
For Kalshi integration we leverage their institutional API tier with dedicated rate limits and priority queue access. Agents can scan active event contracts across politics, economics, weather, and entertainment categories, analyzing contract pricing against implied probabilities and external prediction signals. Our order execution layer handles Kalshi's unique resting order semantics and partial fill logic, automatically managing position lifecycle from entry through expiry or early exit based on agent-defined take profit parameters.
Solana DEX trading is powered by Jupiter Aggregator's V6 API which provides unified liquidity routing across Raydium, Orca, Meteora, Phoenix, and 20+ other AMMs and CLOBs. When an agent requests a token swap, we query Jupiter's quote engine to find optimal routing paths considering price impact, fees, and slippage tolerance. The returned route is packaged into a Solana transaction with agent-controlled keypair signing, then broadcast via our high-performance RPC node cluster with sub-second confirmation targeting. We maintain persistent connections to both public and private Solana RPCs to ensure transaction inclusion even during network congestion.
x402 Usage-Based Payment Protocol
The x402 payment protocol implements deterministic per-execution pricing for agent usage, allowing creators to monetize their agents while maintaining transparent cost structures for users. Each agent defines a pricePerUse denominated in USDC that is charged every time the agent completes an execution cycle including data ingestion, AI inference, and potential trade execution. Payments are processed on-chain via Solana Program Library token transfers, with settlement finality guaranteed within 400 milliseconds.
When a user invokes an agent, the protocol first checks their USDC token account balance against the required payment amount. If sufficient funds exist, an atomic instruction bundle is constructed containing both the payment transfer and agent execution approval. The payment is split according to the agent's configured revenue share parameters, typically 70% to creator, 20% to protocol treasury, and 10% to agent token holder rewards pool. These splits are enforced at the program level ensuring creators cannot be rugged and token holders receive guaranteed yield from agent usage.
Our payment infrastructure maintains a hot wallet cluster for gas abstraction, allowing users to pay for agent executions without holding SOL for transaction fees. We batch multiple agent payments into single transactions when possible to minimize on-chain footprint and maximize capital efficiency. All payment records are indexed in real-time, feeding into creator dashboards that display cumulative revenue, active user counts, and per-agent profitability metrics. The protocol implements a global fee accumulator that periodically distributes platform revenue to COMP governance token stakers.
Autonomous Agent Execution Loop
Each agent runs on our distributed execution infrastructure as an isolated process with dedicated compute resources and memory allocation. The execution loop begins with a scheduled trigger based on the agent's configured update interval, which can range from 30-second high-frequency polling to hourly strategic analysis. Upon trigger, the agent enters data collection phase where it aggregates market snapshots from all configured sources including Polymarket market states, Jupiter token prices, Birdeye analytics, and social sentiment APIs.
The aggregated data is serialized into a structured prompt format containing current portfolio state, open positions with unrealized PnL, recent trade history, and real-time market conditions across all relevant assets. This context package is sent to the selected AI model via our inference proxy with the agent's system prompt prepended. The model returns a chain-of-thought reasoning trace explaining its market analysis followed by a structured decision object indicating either no action, position adjustment, or new trade execution with specific parameters.
If a trade is signaled, our risk management layer validates it against configured bounds including maximum position size as percentage of portfolio, stop-loss proximity to current price, and total portfolio exposure limits. Trades failing risk checks are rejected with detailed reasoning logged to the agent's thought stream. Approved trades enter the execution pipeline where appropriate API calls are constructed for the target market, transactions are signed with the agent's delegated keypair, and orders are submitted with retry logic and timeout handling to ensure reliable execution even during network instability.
Post-execution, the agent's state is updated with new position information, trade records are persisted to the database with immutable signatures, and performance metrics are recalculated including cumulative PnL, win rate, Sharpe ratio, and maximum drawdown. All state changes are broadcast via WebSocket to connected frontend clients for real-time dashboard updates. The agent then enters sleep mode until its next scheduled execution cycle, with position monitoring running continuously in a separate thread to handle stop-loss and take-profit triggers that may fire between active execution windows.
Security & Key Management
Agent keypairs are generated using Solana's ed25519 cryptographic primitives with entropy sourced from hardware random number generators. Private keys are encrypted at rest using AES-256-GCM with key derivation via PBKDF2 and stored in isolated key management service instances running on dedicated hardware security modules. Each agent operates with a delegated keypair that has no access to the creator's main wallet, implementing defense-in-depth segregation between agent treasury and personal funds.
Trade signing occurs in secure enclaves where private key material never leaves hardware boundaries. Transaction payloads are constructed in application space then passed to the HSM for signing, with the returned signature combined with the original transaction for network broadcast. We implement transaction simulation before signing to detect potential failures, honeypot tokens, or malicious smart contract interactions that could drain agent funds. All outbound transactions are rate-limited per agent with circuit breakers that halt trading if loss thresholds are exceeded within specified time windows.