AI Agent Quickstart
This guide is for anyone who wants to run an autonomous agent that trades Quasdaq markets — whether that’s an Entropic agent on Quai, a Claude Code skill, or your own custom bot.
The 30-Second Version
Section titled “The 30-Second Version”- Give your agent a funded Quai wallet
- Have it call
GET /api/feeds?storkOnly=trueto discover tradeable assets - Scan open markets, compare implied odds vs. fair price, bet when there’s edge
- Auto-claim winnings after resolution
That’s it. The rest of this page fills in the details.
Discovery for AI Agents
Section titled “Discovery for AI Agents”Your agent should fetch these on startup:
| URL | What it gets |
|---|---|
https://docs.quasdaq.com/llms.txt | Structured doc index — start here |
https://docs.quasdaq.com/llms-full.txt | All docs concatenated for RAG |
https://quasdaq.com/api/feeds?storkOnly=true | Live feed catalog with exact feedIdHash values |
Critical Rule: Feed IDs
Section titled “Critical Rule: Feed IDs”The #1 agent failure mode is creating markets with wrong feed IDs. An incorrect hash = unresolvable market = funds permanently locked.
// WRONG — will lock funds foreverconst feedId = keccak256(toUtf8Bytes("btcusd")); // wrong casing
// CORRECT — use pre-computed hash from APIconst { feeds } = await fetch("https://quasdaq.com/api/feeds?storkOnly=true").then(r => r.json());const btc = feeds.find(f => f.symbol === "BTC");const feedIdHash = btc.feedIdHash; // guaranteed correctAgent Trading Loop
Section titled “Agent Trading Loop”Here’s the complete loop an autonomous agent should run:
Step 1: Check wallet balance
Section titled “Step 1: Check wallet balance”import { JsonRpcProvider, Wallet, Contract, parseQuai, formatQuai } from "quais";
const provider = new JsonRpcProvider("https://rpc.quai.network");const wallet = new Wallet(PRIVATE_KEY, provider);const balance = await provider.getBalance(wallet.address);console.log(`Balance: ${formatQuai(balance)} QUAI`);Step 2: Scan markets for edge
Section titled “Step 2: Scan markets for edge”const FACTORY = "0x0027Adb36E28fA1C037286Da59BB348fA2B63Bd6";const factory = new Contract(FACTORY, ["function getMarkets() view returns (address[])"], provider);const markets = await factory.getMarkets();
const abi = [ "function question() view returns (string)", "function status() view returns (uint8)", "function yesPool() view returns (uint256)", "function noPool() view returns (uint256)", "function isBettingOpen() view returns (bool)", "function strikePrice() view returns (int256)", "function resolutionTime() view returns (uint256)", "function feedId() view returns (bytes32)"];
for (const addr of markets) { const m = new Contract(addr, abi, provider); const [status, open, yesPool, noPool] = await Promise.all([ m.status(), m.isBettingOpen(), m.yesPool(), m.noPool() ]); if (status !== 0n || !open) continue;
const total = yesPool + noPool; if (total === 0n) continue; const impliedYes = Number(yesPool) / Number(total);
// Compare against your fair probability model // If edge > threshold, bet}Step 3: Place bet
Section titled “Step 3: Place bet”const market = new Contract(addr, ["function betYes() payable", "function betNo() payable"], wallet);await (await market.betYes({ value: parseQuai("10"), gasLimit: 200000n })).wait();Step 4: Claim winnings
Section titled “Step 4: Claim winnings”const market = new Contract(addr, [ "function status() view returns (uint8)", "function calculatePayout(address) view returns (uint256)", "function hasClaimed(address) view returns (bool)", "function claim()"], wallet);
if ((await market.status()) === 1n && !(await market.hasClaimed(wallet.address))) { const payout = await market.calculatePayout(wallet.address); if (payout > 0n) await (await market.claim({ gasLimit: 200000n })).wait();}Simple Edge Model
Section titled “Simple Edge Model”A basic fair probability model for price prediction markets:
- Get current price —
GET /api/price?feedId=BTCUSD - Compare to strike — if current price is well above strike and resolution is soon, Yes probability is high
- Adjust for volatility — more time = more uncertainty = probability closer to 50%
- Compare to implied odds — if your fair probability diverges from the pool ratio by >5%, that’s edge
More sophisticated agents use log-normal models, momentum signals, and Kelly criterion for sizing. See the Economics page for payout math.
Sizing Guidelines
Section titled “Sizing Guidelines”| Rule | Value |
|---|---|
| Max per bet | 15% of bankroll |
| Max total exposure | 40% across all active bets |
| Minimum bankroll | 10 QUAI (practical minimum) |
| Min edge to bet | 5-10% recommended |
On thin pools (under 500 QUAI), your own bet moves the odds against you. Simulate the impact before sizing up.
Constraints Reference
Section titled “Constraints Reference”| Item | Value |
|---|---|
| Network | Quai mainnet (not testnet) |
| RPC | https://rpc.quai.network |
| Gas limit (create market) | 5000000 |
| Gas limit (bet/claim) | 200000 |
| Min seed bet | factory.minSeedBet() (~100 QUAI) |
| Resolvable feeds | BTC, ETH, SOL, BNB, SPY only |
| Address format | Must be checksummed via getAddress() |
| SPY market hours | 9:30 AM - 4:00 PM ET, weekdays only |
Error Handling
Section titled “Error Handling”| Error | What happened | Fix |
|---|---|---|
BettingClosed | Betting window ended | Check isBettingOpen() first |
SeedBetTooLow | Seed below minimum | Query factory.minSeedBet() |
ZeroAmount | Sent 0 QUAI | Include value in tx |
data=null revert | estimateGas crashed | Always set explicit gasLimit |
| Unresolvable market | Wrong feedId hash | Only use feedIdHash from /api/feeds |
Running Autonomously
Section titled “Running Autonomously”Want your agent to run 24/7 without babysitting? Check out the Run an Agent on Entropic guide — deploy the trading loop above as an autonomous agent on Quai’s AI agent platform.