
Introduction
PolyClaw is an innovative OpenClaw skill (formerly known as Clawdbot, then Moltbot) that brings Polymarket trading and arbitrage capabilities directly to your messenger. Built as a messenger-friendly version of the Polymarket Alphabot developed by Chainstack, PolyClaw enables users to monitor markets, execute trades, and discover arbitrage opportunities through a unified interface.
This tutorial will show you how to set up and use PolyClaw for automated prediction market trading, leveraging LLM to analyze logical relationships between events.
The video below provides a practical overview of PolyClaw’s setup and key features.
Key features of the Polymarket OpenClaw bot
- Market Monitoring: Instantly access trending Polymarket data, including market IDs and current prices
- Direct Trading: Buy and sell positions through messenger using simple natural language commands
- LLM-Powered Arbitrage: The ‘Hedge Scan’ feature uses Large Language Models to find logical relationships between markets, not just price correlations
- Automated Position Management: Track open positions with real-time profit and loss calculations
- Split + CLOB Execution: Efficient trading through token splitting mechanism and Central Limit Order Book
Technical architecture of the OpenClaw bot
PolyClaw operates through a synergy of several APIs and blockchain components:
| Component | Description |
| OpenClaw/Moltbot | Base platform running the skill, can be hosted on any server (e.g., Mac Mini) |
| Polymarket Gamma API | Used for reading market data, identifying trending topics, and retrieving market IDs |
| Chainstack Polygon RPC | Handles on-chain transactions on Polygon mainnet, converting USDC into market tokens |
| Polymarket CLOB API | Manages the off-chain Central Limit Order Book. When placing a bet, USDC is split into YES and NO tokens, and the unwanted side is automatically sold |
| OpenRouter API | Connects the system to LLMs (free models available) to perform arbitrage opportunity discovery |
Installation and setup
Step 1: Install the OpenClaw bot skill
💡 Note: You can also clone directly from the GitHub repository if you prefer working with Git.
PolyClaw is a skill (workflow) for OpenClaw – a customizable AI agent platform. Each OpenClaw instance is unique to the user with their chosen set of skills. Recommended method – installation via ClawHub (official skill marketplace for OpenClaw):
clawhub install polyclawcd ~/.openclaw/skills/polyclawuv sync
Alternative method – manual installation:
cp -r polyclaw ~/.openclaw/skills/cd ~/.openclaw/skills/polyclawuv sync
Step 2: Obtain required credentials for OpenClaw bot access
PolyClaw requires three keys:
- Chainstack Polygon RPC endpoint: Sign up at Chainstack (free tier available, sign in with GitHub, X, or Google). Get the RPC URL for Polygon mainnet. Not sure how? We explained it here.
- OpenRouter API Key: Create a key at OpenRouter for LLM access
- EVM Private Key: Wallet private key in hex format (starts with 0x)
⚠️ IMPORTANT: Keep only small amounts in this wallet. Withdraw funds regularly to a secure wallet. Only trade with funds you can afford to lose.
Step 3: Configure the PolyClaw skill environment
Add the following settings to your openclaw.json file under skills.entries.polyclaw.env:
"polyclaw": { "enabled": true, "env": { "CHAINSTACK_NODE": "https://polygon-mainnet.core.chainstack.com/YOUR_KEY", "POLYCLAW_PRIVATE_KEY": "0x...", "OPENROUTER_API_KEY": "sk-or-v1-..." }}
Step 4: Enable trading (First-Time Setup)
Before your first trade, you must set Polymarket contract approvals (one-time operation, costs approximately 0.01 POL in gas):
uv run python scripts/polyclaw.py wallet approve
This command will submit 6 approval transactions to the Polygon network. You only need to do this once per wallet.
Step 5: Prepare funds for the Polymarket bot
The system requires bridged USDC (USDC.e) on the Polygon network:
- Purchase USDC on any crypto exchange
- Transfer it to Polygon network via bridge or exchange
- If necessary, convert to USDC.e through a DEX like QuickSwap
- You’ll also need a small amount of POL for transaction gas fees
How PolyClaw executes trades
Split + CLOB Mechanism
PolyClaw handles Polymarket’s Conditional Token Framework (CTF) automatically. When you buy a position, the skill:
- Split: Splits your USDC.e into equal YES and NO tokens
- Sell: Sells the side you don’t want via the order book
- Result: Returns your desired position at the effective market price
Example of buying YES at $0.65:
- Split: $2 USDC.e → 2 YES + 2 NO tokens
- Sell: 2 NO tokens @ $0.35 → recover ~$0.70
- Net: Paid ~$1.30 for 2 YES tokens (effective price: $0.65)
Arbitrage logic in the PolyClaw skill
PolyClaw moves beyond traditional trading by searching for logical implications between disparate markets.
How the OpenClaw bot finds logical relationships
The LLM analyzes whether the outcome of Market A logically implies the outcome of Market B. For example, if ‘Candidate X wins the presidency’ logically implies ‘Party Y wins the Senate’, the system identifies this relationship.
Important: Only logically necessary implications are accepted. Simple correlations and ‘likely’ relationships are rejected by the system.
Coverage Tiers
| Tier | Coverage | Description |
| Tier 1 (HIGH) | ≥95% | Near-arbitrage, minimal risk |
| Tier 2 (GOOD) | 90-95% | Strong hedging positions |
| Tier 3 (MODERATE) | 85-90% | Decent but noticeable risk |
| Tier 4 (LOW) | <85% | Speculative (filtered by default) |
Using the PolyClaw skill in practice
When using PolyClaw through OpenClaw bot, you interact with natural language. For example:
- “What’s trending on Polymarket?” – Get market IDs and prices
- “Buy $50 YES on market” – Execute a trade
- “Show my positions” – View your portfolio
- “Find hedging opportunities” – Run LLM arbitrage scan
Advanced: Direct CLI Usage (for developers)
You can also interact directly with the skill scripts:
1. Browse trending markets:
uv run python scripts/polyclaw.py markets trending
2. Search markets by keyword:
uv run python scripts/polyclaw.py markets search "election"
3. Check wallet balance:
uv run python scripts/polyclaw.py wallet status
4. Buy a position:
uv run python scripts/polyclaw.py buy <market_id> YES 50
5. View positions:
uv run python scripts/polyclaw.py positions
Complete Workflow Example for PolyClaw skill
💻 Code Examples: For detailed code implementation and advanced examples, see the scripts directory in the GitHub repository.
- Ask the bot: ‘What’s trending on Polymarket?’ – Get market IDs
- Run: ‘Run hedge scan limit 10’ – Wait for LLM analysis (takes a few minutes)
- Review results – You’ll see coverage tiers and market pairs for hedging
- Open position: ‘Buy $25 YES on market abc123’ – Take position on target market
- Hedge: ‘Buy $25 NO on market xyz789’ – Take position on covering market
- Track: ‘Show my PolyClaw positions’ – Check entry prices and P&L
Troubleshooting
Issue: CLOB order failed / IP blocked by Cloudflare
Polymarket’s CLOB API uses Cloudflare protection that blocks POST requests from many IP addresses. The solution is to use a rotating residential proxy with retry logic.
Recommended setup (IPRoyal or similar):
export HTTPS_PROXY="http://user:pass@geo.iproyal.com:12321"export CLOB_MAX_RETRIES=10
The CLOB client automatically retries with new IPs until finding an unblocked one. Typically succeeds within 5-10 attempts.
Issue: Hedge scan finds 0 results or spurious results
Model quality matters. The default nvidia/nemotron-nano-9b-v2:free works well. If using a different model, some may find spurious correlations (false positives), while others return empty responses. Try explicitly specifying the recommended model:
uv run python scripts/polyclaw.py hedge scan --model nvidia/nemotron-nano-9b-v2:free
Issue: Insufficient USDC.e
Check your balance – you need USDC.e (bridged USDC) on Polygon:
uv run python scripts/polyclaw.py wallet status
Important security warnings
- This is experimental software. The private key is stored in the configuration file for convenience
- Keep only small amounts of funds in the bot
- Regularly withdraw funds to a secure wallet
- Only trade with funds you can afford to lose
- The code has not been audited for security
- This software is provided as-is for educational and experimental purposes – it is not financial advice
Conclusion
PolyClaw represents a powerful tool for automated prediction market trading, combining blockchain technology and artificial intelligence capabilities. Using Chainstack infrastructure for Polygon network access, this skill opens new possibilities for discovering arbitrage situations based on logical relationships between events.
It’s important to remember that prediction market trading carries risks, and all code is provided ‘as-is’ without warranties. Always conduct your own research and trade responsibly.
Run trades, scan markets, and hedge with logic. All from your messenger.
Useful Resources
- PolyClaw GitHub Repository: polyclaw
- Original Polymarket Alphabot: polymarket-alpha-bot
- ClawHub (Official OpenClaw skill marketplace): clawhub.ai
- Chainstack Documentation: Creating a Polymarket trading OpenClaw skill
- Polymarket: polymarket.com
- OpenRouter: openrouter.ai
