AI Agents as Prediction Traders: Automating Polymarket with Real Money
AI Agents as Prediction Traders: Automating Polymarket with Real Money
Prediction market trading with AI agents isn't a research concept anymore — it's something you can deploy today, with real money, on Polymarket, using infrastructure that exists right now. The gap between "AI that can reason about probabilities" and "AI that can act on those probabilities in a market" has always been wallet infrastructure. That gap is now closed.
Why This Matters More Than You Think
Polymarket is one of the few places on the internet where being right about the future has immediate, verifiable financial consequences. Prediction markets aggregate information better than most institutions. They're also one of the cleaner venues for AI agents to demonstrate economic judgment — the signal is unambiguous. Either the market resolves in your favor or it doesn't.
But reasoning about outcomes is the easy part. The hard part is the infrastructure layer underneath: How does an agent hold funds? How does it execute a trade without a human approving every click? How do you prevent it from losing everything in a single bad position? These aren't AI problems. They're wallet problems. And they've been largely ignored while everyone focused on making agents smarter.
The moment you want an agent to participate in a prediction market autonomously — not just recommend trades, but actually execute them — you need autonomous wallet infrastructure. Not a custodied account with a human holding the keys. Not a hot wallet you paste into a config file and hope for the best. Something designed from the ground up for agents.
What "Autonomous Wallet Infrastructure" Actually Means
WAIaaS (Wallet-as-a-Service for AI agents) is an open-source, self-hosted daemon that gives AI agents their own wallet with full transaction capabilities, a policy engine that enforces spending rules, and a security model that keeps a human owner in the loop for decisions that matter — without requiring human approval for every small trade.
Here's what that looks like in practice for a Polymarket trading agent.
The agent needs to:
- Hold USDC (Polymarket's settlement token)
- Call Polymarket's smart contracts to place and manage positions
- Stay within predefined risk limits
- Report back to its owner when something significant happens
WAIaaS handles all four. The agent gets a session token. The owner sets policies. The daemon enforces them.
The Policy Engine: Your Risk Manager That Never Sleeps
Before writing a single line of agent code, you configure what the agent is allowed to do. WAIaaS has 21 policy types organized into 4 security tiers: INSTANT, NOTIFY, DELAY, and APPROVAL.
For a Polymarket agent, a reasonable starting configuration looks like this:
# Set a spending limit with tiered security
curl -X POST http://127.0.0.1:3100/v1/policies \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{
"walletId": "<wallet-uuid>",
"type": "SPENDING_LIMIT",
"rules": {
"instant_max_usd": 100,
"notify_max_usd": 500,
"delay_max_usd": 2000,
"delay_seconds": 900,
"daily_limit_usd": 5000
}
}'
What this does: any trade under $100 executes immediately with no notification. Trades between $100–$500 execute immediately but you get a notification. Trades between $500–$2,000 go into a 15-minute queue — you can cancel them. Anything over $2,000 requires explicit human approval. The daily cap is $5,000 regardless.
This is exactly how you'd configure a junior trader with a defined mandate. The agent has real autonomy within the envelope. You retain control over decisions outside it.
You'd also configure a CONTRACT_WHITELIST to make sure the agent can only interact with Polymarket's contracts — nothing else:
curl -X POST http://127.0.0.1:3100/v1/policies \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{
"walletId": "<wallet-uuid>",
"type": "CONTRACT_WHITELIST",
"rules": {
"contracts": [{"address": "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045", "name": "Polymarket CTF Exchange", "chain": "polygon"}]
}
}'
WAIaaS enforces default-deny: if CONTRACT_WHITELIST is configured, the agent cannot call any contract that isn't on the list. Even if the agent's reasoning goes completely sideways and it tries to do something else with the funds, the policy layer blocks it at the daemon level — before the transaction ever hits the network.
The Polymarket integration itself is available through the polymarket provider, which is one of WAIaaS's 15 integrated DeFi protocol providers.
Giving the Agent Its Session Token
The wallet is created by a human administrator using the master password. The agent operates using a session token — a scoped credential that can be revoked at any time.
# Create the wallet (you do this once)
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"name": "polymarket-agent", "chain": "evm", "environment": "mainnet"}'
# Create a session for the agent (scoped to this wallet)
curl -X POST http://127.0.0.1:3100/v1/sessions \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"walletId": "<wallet-uuid>"}'
The session token goes into your agent's environment. The agent never sees the master password. It can't create new wallets, change policies, or touch anything outside its session scope. This is the authentication separation that makes autonomous operation safe: three distinct auth layers (masterAuth, sessionAuth, ownerAuth) with different capabilities and different holders.
Sessions support per-session TTL, maximum renewals, and absolute lifetime limits — so a compromised session has a hard expiry.
The Agent Code: Checking Balance and Executing a Trade
Once the agent has a session token, it operates through the REST API or the TypeScript SDK. Here's what a minimal Polymarket trading loop looks like using the SDK:
import { WAIaaSClient, WAIaaSError } from '@waiaas/sdk';
const client = new WAIaaSClient({
baseUrl: process.env['WAIAAS_BASE_URL'] ?? 'http://localhost:3100',
sessionToken: process.env['WAIAAS_SESSION_TOKEN'],
});
// Check available balance before placing any position
const balance = await client.getBalance();
console.log(`Available: ${balance.balance} ${balance.symbol} on ${balance.chain}/${balance.network}`);
// Agent reasoning happens here — probability assessment, Kelly criterion sizing, etc.
// Once the agent decides to place a trade, it submits via the actions API
The actual Polymarket position is executed through the polymarket action provider. The agent calls the action endpoint with the position details, and WAIaaS handles the rest: policy validation, transaction construction, signing, and submission.
If the transaction is within the INSTANT tier, it goes through immediately. If it hits the NOTIFY tier, it executes and the owner gets a notification. If it's large enough to require DELAY or APPROVAL, the agent gets back a pending transaction ID and can poll for status.
# Check a pending transaction status
curl http://127.0.0.1:3100/v1/transactions/<tx-id> \
-H "Authorization: Bearer wai_sess_<token>"
Simulating Before You Commit Real Money
Before the agent goes live, you can run every transaction in dry-run mode. The simulation API evaluates the full pipeline — policy checks, balance validation, transaction construction — without actually submitting anything to the network.
curl -X POST http://127.0.0.1:3100/v1/transactions/send \
-H "Content-Type: application/json" \
-H "Authorization: Bearer wai_sess_<token>" \
-d '{
"type": "TRANSFER",
"to": "recipient-address",
"amount": "0.1",
"dryRun": true
}'
Run your agent in dry-run mode for a week. Watch what it would have done. Tune the policies. Then flip the switch.
When the Agent Needs Human Sign-Off
For positions above your APPROVAL threshold, the owner gets a notification and can approve or reject via WalletConnect, Telegram, or a push notification. The transaction sits in the queue until the owner acts.
# Owner approves a pending large position
curl -X POST http://127.0.0.1:3100/v1/transactions/<tx-id>/approve \
-H "X-Owner-Signature: <ed25519-or-secp256k1-signature>" \
-H "X-Owner-Message: <signed-message>"
WAIaaS has 3 signing channels built in: push relay, Telegram, and wallet notification. The owner can approve from a phone while the agent continues operating normally on everything within its autonomous envelope.
This is the human-in-the-loop model that actually scales. Not "approve every trade" — that's not autonomous. Not "approve nothing" — that's not safe. The policy engine defines the boundary, and the agent operates freely within it.
Connecting to Claude or Any MCP-Compatible Agent
If you're using Claude or another MCP-compatible agent framework, WAIaaS exposes 45 MCP tools that cover the full wallet and trading surface. Setup is one command:
waiaas mcp setup --all
Then add the configuration to Claude Desktop:
{
"mcpServers": {
"waiaas-polymarket": {
"command": "npx",
"args": ["-y", "@waiaas/mcp"],
"env": {
"WAIAAS_BASE_URL": "http://127.0.0.1:3100",
"WAIAAS_SESSION_TOKEN": "wai_sess_<your-token>",
"WAIAAS_DATA_DIR": "~/.waiaas"
}
}
}
}
Claude can now call get_balance, execute_action with the Polymarket provider, get_defi_positions, and simulate_transaction directly. The conversation becomes the trading interface. The policies you set in WAIaaS are the guardrails Claude operates within, regardless of what prompt someone feeds it.
Quick Start: Get a Polymarket Agent Running
Here's the minimal path from zero to a running agent:
Step 1: Install and start WAIaaS
npm install -g @waiaas/cli
waiaas init
waiaas start
Step 2: Create a wallet and configure policies
# Create the agent wallet
curl -X POST http://127.0.0.1:3100/v1/wallets \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"name": "polymarket-agent", "chain": "evm", "environment": "mainnet"}'
# Set spending limits
curl -X POST http://127.0.0.1:3100/v1/policies \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"walletId": "<wallet-uuid>", "type": "SPENDING_LIMIT", "rules": {"instant_max_usd": 100, "notify_max_usd": 500, "delay_max_usd": 2000, "delay_seconds": 900, "daily_limit_usd": 5000}}'
Step 3: Create a session token for your agent
curl -X POST http://127.0.0.1:3100/v1/sessions \
-H "Content-Type: application/json" \
-H "X-Master-Password: my-secret-password" \
-d '{"walletId": "<wallet-uuid>"}'
Step 4: Install the SDK and start building
npm install @waiaas/sdk
Step 5: Run in dry-run mode first. Test your agent's logic against real market conditions without risking funds. Watch the policy engine catch anything outside your configured parameters.
The Deeper Point
What makes this interesting isn't Polymarket specifically. It's the model it demonstrates: an AI agent with a real economic presence, operating within a policy envelope defined by a human owner, capable of autonomous action within that envelope and escalation outside it.
Prediction markets are one of the cleaner test cases because the feedback loop is tight and objective. But the same infrastructure — scoped session tokens, a 21-type policy engine, 7-stage transaction pipeline, incoming transaction monitoring, and human-in-the-loop approval channels — applies to any economic activity you want an agent to perform.
The question "how do AI agents participate in economic activity" now has a working answer. The infrastructure exists. What agents do with it is the open question.
What's Next
The WAIaaS Admin UI at /admin gives you a real-time view of your agent's positions, transaction history, and policy status without touching the API. For production deployments, the Docker setup with secrets overlay handles credential management properly — worth reading before you go live with real funds.
Explore the codebase and full documentation on GitHub at https://github.com/waiaas/WAIaaS, or visit https://waiaas.ai for the official site. The OpenAPI spec and interactive API reference are available at /doc and /reference once your daemon is running — start there to understand the full surface area before building your agent.