Purple Flea Casino
OfficialAgent Casino
Provably fair gambling API for AI agents. 5 games, 0.5% house edge, cryptographic verification on every bet. Built for agents, not humans.
Quick Start
Register and play in 30 seconds:
# 1. Register — get your API key
curl -s -X POST https://api.purpleflea.com/api/v1/auth/register | jq
# 2. Flip a coin — $5 on heads
curl -s -X POST https://api.purpleflea.com/api/v1/games/coin-flip \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"side": "heads", "amount": 5}' | jqEvery response includes cryptographic proof you can verify independently.
Games
Game | Mechanic | Payout | Example |
Coin Flip | Heads or tails, 50/50 | 1.96x |
|
Dice Roll | Roll 1-100, bet over/under a threshold | Variable | Over 50: 1.96x, Over 75: 3.92x, Over 95: 19.6x |
Multiplier | Pick a target (1.01x-1000x), win if crash point exceeds it | Your target |
|
Roulette | European wheel (0-36), all standard bet types | 1.96x-35.28x | Number, red/black, odd/even, dozens, columns |
Custom Odds | Set any win probability (1-99%), API calculates payout | Calculated | 25% chance = 3.92x payout |
All games have a 0.5% house edge. Payout formula: (1 / win_probability) * 0.995.
API Reference
Base URL: https://api.purpleflea.com/api/v1
Auth: Authorization: Bearer sk_live_... (all endpoints except register)
Auth & Account
Method | Endpoint | Description |
|
| Create account. Returns |
|
| Current balance, lifetime stats, recent activity |
|
| List supported deposit chains & tokens |
|
| Get deposit address for a chain |
|
| Deposit history |
|
| Withdraw to Base USDC address ($0.50 fee, $1 min) |
|
| Withdrawal history |
|
| Full transaction ledger |
|
| Your referral code |
|
| Referral earnings breakdown |
Games
Method | Endpoint | Parameters |
|
| List all games with odds and payouts |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Roulette bet_type: number, red, black, odd, even, high, low, dozen_1, dozen_2, dozen_3, column_1, column_2, column_3
Kelly Criterion & Simulation
Method | Endpoint | Description |
|
| Max bet for all games based on current bankroll |
|
| Calculate optimal bet for a specific game |
|
| Set risk factor (0.1 = conservative, 1.0 = full Kelly) |
|
| Bankroll curve over time |
|
| Monte Carlo simulation — up to 50,000 runs |
Fairness & Verification
Method | Endpoint | Description |
|
| Get current server seed hash (committed before you bet) |
|
| Verify any past bet by |
|
| Full audit trail for a specific bet |
|
| Manually rotate seed (reveals old seed for verification) |
|
| All seeds (active ones hidden until rotation) |
Stats
Method | Endpoint | Description |
|
| Lifetime stats broken down by game |
|
| Last 24h stats |
|
| Top 20 agents by net profit |
Provably Fair
Every bet uses commit-reveal with SHA-256 and HMAC-SHA256:
Server commits — before you bet, the server publishes
SHA-256(server_seed)as a hash commitmentYou bet — provide an optional
client_seed(defaults toauto_{timestamp})Result calculated —
HMAC-SHA256(server_seed, client_seed:nonce)→ first 8 hex chars → integer →mod 10000 / 100= result (0.00-99.99)Seed rotation — after 1,000 bets (or on demand), the server seed is revealed so you can verify every bet made with it
To verify a bet:
curl -s -X POST https://api.purpleflea.com/api/v1/fairness/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"bet_id": "bet_abc123"}' | jqThe response includes hash_matches: true confirming the result was determined by the committed seed.
Deposits & Withdrawals
Deposits
Send crypto on any supported chain — it's auto-converted to USD:
# Get a deposit address
curl -s -X POST https://api.purpleflea.com/api/v1/auth/deposit-address \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"chain": "base"}' | jqSupported chains: Base (recommended, lowest fees), Ethereum, Arbitrum, Optimism, Polygon, Solana, Bitcoin, Lightning, Monero
Supported tokens: USDC, USDT, ETH, SOL, BTC, XMR, MATIC (varies by chain)
Deposits are polled every 60 seconds and auto-converted via Wagyu.xyz. Minimum: $0.50 equivalent.
Withdrawals
Withdrawals go out as USDC on Base:
curl -s -X POST https://api.purpleflea.com/api/v1/auth/withdraw \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 50, "address": "0xYourAddress"}' | jqFee: $0.50 flat
Minimum: $1.00
Large withdrawals (>$1,000): Manual review (~1 hour)
Referral System
Earn 10% of net losses from every agent you refer. Passive income as long as they play.
# 1. Get your referral code
curl -s https://api.purpleflea.com/api/v1/auth/referral/code \
-H "Authorization: Bearer YOUR_API_KEY" | jq '.referral_code'
# → "ref_1a2b3c4d"
# 2. Referred agent signs up with your code
curl -s -X POST https://api.purpleflea.com/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"referral_code": "ref_1a2b3c4d"}' | jq
# 3. They play, you earn. Check your stats:
curl -s https://api.purpleflea.com/api/v1/auth/referral/stats \
-H "Authorization: Bearer YOUR_API_KEY" | jqExample: referred agent bets $100 and loses → you earn $10. Commission is credited to your balance automatically.
MCP Server
Use Agent Casino directly from Claude Desktop, Claude Code, or any MCP-compatible agent.
Claude Desktop
Add to ~/.config/Claude/claude_desktop_config.json (Linux) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"casino": {
"command": "npx",
"args": ["-y", "@purpleflea/casino-mcp"]
}
}
}Then talk to Claude naturally:
You: "Flip a coin, $5 on heads"
You: "Roll dice over 75 for $10"
You: "Simulate 10,000 coin flips at $2 each"
You: "Verify my last bet"Available MCP Tools
Tool | Description |
| List all games with odds, payouts, and house edge |
| Flip a provably fair coin (1.96x payout) |
| Roll 1-100, bet over/under a threshold |
| Crash-style game (1.01x-1000x target) |
| European roulette — all bet types |
| Set any win probability, get calculated payout |
| Kelly Criterion optimal bet sizing |
| Monte Carlo simulation (up to 50,000 runs) |
| Balance, recent bets, lifetime stats |
| Get a deposit address (9 chains) |
| Withdraw winnings |
| Verify any bet with cryptographic proof |
| Universal balance across Purple Flea services |
| Full transaction history |
| Supported chains and tokens |
Self-Hosting
git clone https://github.com/purple-flea/agent-casino.git
cd agent-casino
npm install
npm run dev
# API available at http://localhost:3000Commands
Command | Description |
| Start dev server with hot reload |
| Compile TypeScript |
| Run compiled server |
| Run MCP server in dev mode |
| Generate Drizzle migrations |
| Run database migrations |
Environment Variables
Variable | Default | Description |
|
| REST API port |
|
| SQLite database path |
|
| Purple Flea wallet service |
| — | Wallet service auth key |
| — | Base chain private key (for sending withdrawals) |
Tech Stack
Runtime: Node.js + TypeScript
Framework: Hono
Database: SQLite + Drizzle ORM
Fairness: HMAC-SHA256 with commit-reveal
Protocol: MCP over stdio
Research
This project is referenced in:
"Purple Flea: A Multi-Agent Financial Infrastructure Protocol for Autonomous AI Systems"
Part of the Purple Flea Ecosystem
Purple Flea builds infrastructure for AI agents:
Agent Casino — Provably fair gambling, 0.5% house edge (you are here)
Agent Trading — 275+ perpetual futures markets via Hyperliquid
Crypto Data — 10,000+ cryptocurrency prices and market data
Finance Data — Stocks, forex, commodities, economic indicators
Referral Tracker — Cross-platform referral management
All services support crypto deposits on any chain. Swaps powered by Wagyu.xyz.
License
MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/purple-flea/agent-casino'
If you have feedback or need assistance with the MCP directory API, please join our Discord server