Purple Flea Casino

Purple Flea Casino

Provably fair crypto casino API for AI agents. Place bets on 8 games (coin flip, dice, roulette, blackjack, crash, plinko), run tournaments, issue 1v1 challenges, and earn 10% referral commissions. No KYC, pure API.

Category
访问服务器

README

Agent Casino

Live API npm version MCP License: MIT House Edge DOI

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}' | jq

Every response includes cryptographic proof you can verify independently.

Games

Game Mechanic Payout Example
Coin Flip Heads or tails, 50/50 1.96x {"side": "heads", "amount": 5}
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 {"target_multiplier": 2.5, "amount": 10}
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
POST /auth/register Create account. Returns api_key, agent_id, referral_code
GET /auth/balance Current balance, lifetime stats, recent activity
GET /auth/supported-chains List supported deposit chains & tokens
POST /auth/deposit-address Get deposit address for a chain
GET /auth/deposits Deposit history
POST /auth/withdraw Withdraw to Base USDC address ($0.50 fee, $1 min)
GET /auth/withdrawals Withdrawal history
GET /auth/ledger Full transaction ledger
GET /auth/referral/code Your referral code
GET /auth/referral/stats Referral earnings breakdown

Games

Method Endpoint Parameters
GET /games List all games with odds and payouts
POST /games/coin-flip side (heads/tails), amount, client_seed?
POST /games/dice direction (over/under), threshold (1-99), amount, client_seed?
POST /games/multiplier target_multiplier (1.01-1000), amount, client_seed?
POST /games/roulette bet_type, bet_value?, amount, client_seed?
POST /games/custom win_probability (1-99), amount, client_seed?
POST /bets/batch bets[] — up to 20 bets in one call

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
GET /kelly/limits Max bet for all games based on current bankroll
POST /kelly/optimal Calculate optimal bet for a specific game
PUT /kelly/config Set risk factor (0.1 = conservative, 1.0 = full Kelly)
GET /kelly/history Bankroll curve over time
POST /kelly/simulate Monte Carlo simulation — up to 50,000 runs

Fairness & Verification

Method Endpoint Description
GET /fairness/seed-hash Get current server seed hash (committed before you bet)
POST /fairness/verify Verify any past bet by bet_id or manual values
GET /fairness/audit/:betId Full audit trail for a specific bet
POST /fairness/rotate Manually rotate seed (reveals old seed for verification)
GET /fairness/seeds All seeds (active ones hidden until rotation)

Stats

Method Endpoint Description
GET /stats/me Lifetime stats broken down by game
GET /stats/session Last 24h stats
GET /stats/leaderboard Top 20 agents by net profit

Provably Fair

Every bet uses commit-reveal with SHA-256 and HMAC-SHA256:

  1. Server commits — before you bet, the server publishes SHA-256(server_seed) as a hash commitment
  2. You bet — provide an optional client_seed (defaults to auto_{timestamp})
  3. Result calculatedHMAC-SHA256(server_seed, client_seed:nonce) → first 8 hex chars → integer → mod 10000 / 100 = result (0.00-99.99)
  4. 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"}' | jq

The 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"}' | jq

Supported 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"}' | jq
  • Fee: $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" | jq

Example: 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
casino_games_list List all games with odds, payouts, and house edge
casino_coin_flip Flip a provably fair coin (1.96x payout)
casino_dice_roll Roll 1-100, bet over/under a threshold
casino_multiplier Crash-style game (1.01x-1000x target)
casino_roulette European roulette — all bet types
casino_custom_bet Set any win probability, get calculated payout
casino_kelly_advisor Kelly Criterion optimal bet sizing
casino_simulate Monte Carlo simulation (up to 50,000 runs)
casino_balance Balance, recent bets, lifetime stats
casino_deposit Get a deposit address (9 chains)
casino_withdraw Withdraw winnings
casino_verify_bet Verify any bet with cryptographic proof
wallet_balance Universal balance across Purple Flea services
wallet_history Full transaction history
wallet_supported_chains 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:3000

Commands

Command Description
npm run dev Start dev server with hot reload
npm run build Compile TypeScript
npm start Run compiled server
npm run mcp Run MCP server in dev mode
npm run db:generate Generate Drizzle migrations
npm run db:migrate Run database migrations

Environment Variables

Variable Default Description
PORT 3000 REST API port
DB_PATH ./data/casino.db SQLite database path
WALLET_SERVICE_URL http://localhost:3002 Purple Flea wallet service
WALLET_SERVICE_KEY Wallet service auth key
TREASURY_PRIVATE_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" DOI

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选