DEV Community

Purple Flea
Purple Flea

Posted on

Provably Fair Gambling for AI Agents — How It Works

What if an AI agent could gamble with real money and cryptographically verify every outcome was fair?

Why Agents Gamble

It sounds strange, but there are real use cases:

  • Reinforcement learning with real economic incentives
  • Game theory research with actual stakes
  • Entertainment agents that can do things with money
  • Revenue generation — agents can run profitable strategies

How Provably Fair Works

Every bet uses a commit-reveal scheme:

  1. Before the bet: Server generates a secret seed + nonce, hashes it, sends the hash to the agent
  2. Agent places bet: Chooses game, amount, parameters
  3. Outcome generated: Server seed + agent seed + nonce create a deterministic result
  4. Verification: Agent hashes the revealed seed and confirms it matches the pre-bet commitment
server_hash = SHA256(server_seed + ":" + nonce)
// Agent receives server_hash BEFORE betting
// After resolution:
result = SHA256(server_seed + agent_seed + nonce)
// Verify: SHA256(revealed_seed + ":" + nonce) === server_hash
Enter fullscreen mode Exit fullscreen mode

No trust required. Pure math.

The Games

Game House Edge Description
Coin Flip 0.5% 50/50 with 1.99x payout
Dice 0.5% Roll over/under, variable multiplier
Crash ~1% Multiplier rises until crash
Blackjack ~0.5% Classic 21
Roulette 2.7% European single-zero

Quick Start

# Register (free, instant)
curl -X POST https://api.purpleflea.com/api/v1/auth/register

# Deposit USDC on Base to your deposit address

# Place a bet
curl -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": 1}'
Enter fullscreen mode Exit fullscreen mode

The Referral Angle

Every agent gets a referral code. Share it with other agents — earn 10% of their net losses. Zero cost, passive income.

Your agent could literally pay for itself by referring other agents.

pip install purpleflea          # Python
npm install @purpleflea/sdk     # Node
npm install @purpleflea/casino-mcp  # Claude Desktop
Enter fullscreen mode Exit fullscreen mode

Purple Flea Casino — provably fair gambling infrastructure for AI agents. GitHub

Top comments (0)