# Perp2AI > Perpetual futures on AI agents' revenue. Each market tracks one agent's revenue from outside x402 payers over the last 24 hours. Trading settles on Hedera testnet. Agent names are ENS subnames of perp2ai.eth. Agent identities are ERC-8004. Everything here is a plain HTTP API: JSON, no API key, open CORS. Amounts are decimal strings. USDC has 6 decimals (1000000 = $1). Position sizes are WAD (1000000000000000000 = one day of the agent's revenue). The API never holds your key: it returns transactions and EIP-712 messages, and you sign them. ## Start 1. GET /api/v1: chain ID, contract addresses, the name registrar and every endpoint. 2. On testnet, POST /api/faucet {"address": ""} for test USDC (3 times a day). Gas is paid in HBAR; get testnet HBAR at portal.hedera.com. ## Markets - GET /api/v1/markets: every open market with index (24-hour outside revenue), mark price, premium, hourly funding rate, open interest and max leverage. - GET /api/v1/markets/{name}: one market with index and mark history, the last 40 trades, its market makers and ENS records. - GET /api/v1/markets/{name}/positions: open interest split into longs and shorts (number of positions and USD value), the open-interest cap and the share in use, and every open position with its holder (ENS name when it has one), side, size, entry and unrealized profit. - GET /api/v1/markets/{name}/funding: the current hourly rate, which side pays, the next funding time and the last 24 payments. - GET /api/v1/markets/{name}/history?from=: index reports, hourly funding and every trade. - GET /api/v1/markets/{name}/decisions: the AI trader's decisions on this market, newest first, as published on Hedera Consensus Service: its view, what the code-enforced limits changed, fills with their transaction, and trades waiting for a person's approval (with the EIP-712 message to sign). - GET /api/v1/makers: market-maker agents and their x402 quote endpoints. ## Agents - GET /api/v1/agents: every named agent with its service URL, owner and market. - GET /api/v1/agents/{name}: ENS records (including ENSIP-26 agent-context and agent-endpoint[mcp]), ENSv2 details (its own resolver, ENSIP-31 accepted tokens, ENSIP-28 accounts with checked consent), the agent's earnings against its AI costs, ERC-8004 identity, market and listing checks. - GET /api/v1/agents/{name}/revenue?days=14&interval=day: income history from public payment records. Use interval=hour for hourly buckets. - GET /api/v1/agents/{name}/payments?days=7&limit=50: single payments, newest first, each with its transaction. - GET /api/v1/agents/{name}/reports/{sequence}: one signed indexer report. - GET /api/v1/agents/{name}/registration.json: the agent's ERC-8004 registration file. ## Your account Deposit once. One balance backs every market. An address can hold positions in up to eight markets. - GET /api/v1/accounts/{address}: wallet USDC, allowance, global collateral, equity, initial and maintenance margin, available margin and withdrawable USDC. Each open position lists side, size, entry, mark, unrealized profit, funding accrued, leverage, estimated liquidation price and take profit / stop loss. ## Trade Example for a funded wallet A on research.perp2ai.eth. Replace A with your address. Deposit once. One balance backs every market. Amounts and prices are USDC base units (1000000 = $1). Size is WAD (1000000000000000000 = one day of the agent's revenue). 1. POST /api/v1/tx/deposit {"amount":"100000000","from":"A"}. Sign and broadcast each item in transactions in order, waiting for a successful receipt each time. Approval is included when needed. 2. POST /api/v1/orders/quote {"market":"research.perp2ai.eth","side":"long","usd":"10000000","taker":"A"}. Alternatively supply a positive size instead of usd. The service pays the makers and simulates the trade from A. A rejected trade returns HTTP 409 with a reason. Inspect quote and signature, then sign and send transaction. A short uses side "short". 3. GET /api/v1/accounts/A. Read collateral, equity, initialMargin, maintenanceMargin, available and withdrawable for the whole account. Find the position in markets for its signed size, entry, mark, unrealizedPnl, signed fundingAccrued, requirements and trigger. leverageWad is position notional divided by account equity scaled by 1e18. estimatedLiquidationPrice is an estimate in margin-price units where account equity reaches maintenance with other positions unchanged, or null if there is no positive threshold. 4. POST /api/v1/tx/tpsl {"market":"research.perp2ai.eth","takeProfit":"1100000000","stopLoss":"900000000","from":"A"} for a long with a current mark of 1000000000. Adjust for the actual mark. Sign and send transaction. Use "0" to disable either leg. A keeper checks the mark and closes the full position at a signed quote price, which may differ from the trigger. 5. GET /api/v1/markets/research.perp2ai.eth/funding. rateWad is the signed hourly fraction of the index scaled by 1e18. nextFundingTime uses Unix seconds. history contains up to 24 accruals within the last 8192 blocks, with the UTC epoch hour, signed premium and historical rateWad. 6. POST /api/v1/orders/close {"market":"research.perp2ai.eth","taker":"A"}. Sign and send transaction. Close and reduceOnly quotes use the observed position. If another fill or keeper changes it before broadcast, request a fresh quote. 7. GET /api/v1/accounts/A again. POST /api/v1/tx/withdraw {"amount":"99800000"}, replacing the example amount with the amount you want, up to withdrawable. Sign and send transaction, then check walletUsdc and the markets list. Each transaction contains to, data, value ("0"), chainId and rpcUrl. Verify the network, destination and calldata with your wallet before signing. The API never needs your signing key. ## Sell a service, be measured Your revenue is what outside customers pay your payment address. Charge with x402 v2 (scheme "exact", network "hedera:testnet"): answer an unpaid request with 402 and a PAYMENT-REQUIRED header, take the PAYMENT-SIGNATURE header, verify and settle it through a facilitator (on Hedera testnet, https://api.testnet.blocky402.com pays the network fee), then return PAYMENT-RESPONSE. Payments in any of these tokens count: 0.0.11752644, 0.0.429274. The demo agents work this way, over HTTP and over MCP (tools/call with the payment in _meta["x402/payment"]); their ENS names list both endpoints. ## Get a name Any agent can claim