Skip to content

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.

  1. Give your agent a funded Quai wallet
  2. Have it call GET /api/feeds?storkOnly=true to discover tradeable assets
  3. Scan open markets, compare implied odds vs. fair price, bet when there’s edge
  4. Auto-claim winnings after resolution

That’s it. The rest of this page fills in the details.

Your agent should fetch these on startup:

URLWhat it gets
https://docs.quasdaq.com/llms.txtStructured doc index — start here
https://docs.quasdaq.com/llms-full.txtAll docs concatenated for RAG
https://quasdaq.com/api/feeds?storkOnly=trueLive feed catalog with exact feedIdHash values

The #1 agent failure mode is creating markets with wrong feed IDs. An incorrect hash = unresolvable market = funds permanently locked.

// WRONG — will lock funds forever
const feedId = keccak256(toUtf8Bytes("btcusd")); // wrong casing
// CORRECT — use pre-computed hash from API
const { 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 correct

Here’s the complete loop an autonomous agent should run:

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`);
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
}
const market = new Contract(addr, ["function betYes() payable", "function betNo() payable"], wallet);
await (await market.betYes({ value: parseQuai("10"), gasLimit: 200000n })).wait();
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();
}

A basic fair probability model for price prediction markets:

  1. Get current priceGET /api/price?feedId=BTCUSD
  2. Compare to strike — if current price is well above strike and resolution is soon, Yes probability is high
  3. Adjust for volatility — more time = more uncertainty = probability closer to 50%
  4. 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.

RuleValue
Max per bet15% of bankroll
Max total exposure40% across all active bets
Minimum bankroll10 QUAI (practical minimum)
Min edge to bet5-10% recommended

On thin pools (under 500 QUAI), your own bet moves the odds against you. Simulate the impact before sizing up.

ItemValue
NetworkQuai mainnet (not testnet)
RPChttps://rpc.quai.network
Gas limit (create market)5000000
Gas limit (bet/claim)200000
Min seed betfactory.minSeedBet() (~100 QUAI)
Resolvable feedsBTC, ETH, SOL, BNB, SPY only
Address formatMust be checksummed via getAddress()
SPY market hours9:30 AM - 4:00 PM ET, weekdays only
ErrorWhat happenedFix
BettingClosedBetting window endedCheck isBettingOpen() first
SeedBetTooLowSeed below minimumQuery factory.minSeedBet()
ZeroAmountSent 0 QUAIInclude value in tx
data=null revertestimateGas crashedAlways set explicit gasLimit
Unresolvable marketWrong feedId hashOnly use feedIdHash from /api/feeds

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.