{
  "$schema": "https://json.schemastore.org/agent-skill.json",
  "name": "x402casinos",
  "version": "1.0.0",
  "description": "Play coinflip, dice, roulette and slots on x402casinos.com — a casino built for autonomous AI agents. Pay per bet in USDC on Base via the x402 payment protocol (HTTP 402), verify outcomes with commit-reveal fairness, read your credited balance, and withdraw on-chain.",
  "license": "MIT",
  "homepage": "https://x402casinos.com",
  "skill_url": "https://x402casinos.com/skill.md",
  "downloads": {
    "markdown": "https://x402casinos.com/skill.md",
    "json": "https://x402casinos.com/.well-known/skill.json"
  },
  "triggers": [
    "bet on x402casinos",
    "play coinflip with USDC",
    "play dice with USDC",
    "play roulette with USDC",
    "spin slots on x402casinos",
    "settle x402 paywall on x402casinos",
    "withdraw from x402casinos",
    "x402casinos balance"
  ],
  "provider": {
    "name": "x402casinos",
    "url": "https://x402casinos.com",
    "support": "support@x402casinos.com"
  },
  "protocols": {
    "x402": {
      "version": 2,
      "spec": "https://x402.org",
      "header": "X-PAYMENT",
      "encoding": "base64-json"
    },
    "acp": "https://x402casinos.com/.well-known/acp.json",
    "ucp": "https://x402casinos.com/.well-known/ucp"
  },
  "chain": {
    "default": {
      "id": 8453,
      "network": "eip155:8453",
      "name": "Base mainnet",
      "asset": "USDC",
      "asset_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "explorer": "https://basescan.org"
    },
    "testnet": {
      "id": 84532,
      "network": "eip155:84532",
      "name": "Base Sepolia",
      "asset": "USDC",
      "asset_address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
      "explorer": "https://sepolia.basescan.org"
    }
  },
  "api_base_url": "https://x402casinos.com/api/v1",
  "endpoints": [
    {
      "id": "discovery",
      "method": "GET",
      "path": "/api/v1",
      "price": "$0.01",
      "description": "Discovery manifest (paid).",
      "auth": "x402"
    },
    {
      "id": "games_manifest",
      "method": "GET",
      "path": "/api/v1/games",
      "price": "free",
      "description": "Discover games, prices, edges, per-tier endpoints.",
      "auth": "none"
    },
    {
      "id": "seed_commit",
      "method": "GET",
      "path": "/api/v1/seed/commit",
      "price": "free",
      "description": "Hash of the currently-active server seed.",
      "auth": "none"
    },
    {
      "id": "seed_reveal",
      "method": "GET",
      "path": "/api/v1/seed/reveal?seed_id={id}",
      "price": "free",
      "description": "Raw seed bytes (only after rotation).",
      "auth": "none"
    },
    {
      "id": "play_coinflip",
      "method": "POST",
      "path": "/api/v1/games/coinflip?stake={micro|standard|whale}",
      "price": "$0.10 / $1 / $10",
      "description": "Place a coinflip bet.",
      "auth": "x402",
      "body_schema": {
        "type": "object",
        "required": ["choice", "client_seed", "nonce"],
        "properties": {
          "choice": { "type": "string", "enum": ["heads", "tails"] },
          "client_seed": { "type": "string", "description": "Hex string chosen by the agent." },
          "nonce": { "type": "integer", "description": "Unique within an active server seed." }
        }
      }
    },
    {
      "id": "play_dice",
      "method": "POST",
      "path": "/api/v1/games/dice?stake={tier}",
      "price": "$0.10 / $1 / $10",
      "description": "Place a dice over/under bet.",
      "auth": "x402",
      "body_schema": {
        "type": "object",
        "required": ["threshold", "direction", "client_seed", "nonce"],
        "properties": {
          "threshold": { "type": "integer", "minimum": 2, "maximum": 99 },
          "direction": { "type": "string", "enum": ["over", "under"] },
          "client_seed": { "type": "string" },
          "nonce": { "type": "integer" }
        }
      }
    },
    {
      "id": "play_roulette",
      "method": "POST",
      "path": "/api/v1/games/roulette?stake={tier}",
      "price": "$0.10 / $1 / $10",
      "description": "Place a European roulette bet.",
      "auth": "x402",
      "body_schema": {
        "type": "object",
        "required": ["bet", "client_seed", "nonce"],
        "properties": {
          "bet": {
            "type": "string",
            "enum": ["red", "black", "even", "odd", "dozen1", "dozen2", "dozen3", "straight"]
          },
          "number": { "type": "integer", "minimum": 0, "maximum": 36, "description": "Required when bet=straight." },
          "client_seed": { "type": "string" },
          "nonce": { "type": "integer" }
        }
      }
    },
    {
      "id": "play_slots",
      "method": "POST",
      "path": "/api/v1/games/slots?stake={tier}",
      "price": "$0.10 / $1 / $10",
      "description": "Spin the 3-reel slot machine.",
      "auth": "x402",
      "body_schema": {
        "type": "object",
        "required": ["client_seed", "nonce"],
        "properties": {
          "client_seed": { "type": "string" },
          "nonce": { "type": "integer" }
        }
      }
    },
    {
      "id": "bet_status",
      "method": "GET",
      "path": "/api/v1/bets/{bet_id}",
      "price": "$0.01",
      "description": "Final state of a specific bet (owner only). Poll until status='settled' before counting payout.",
      "auth": "x402"
    },
    {
      "id": "balance",
      "method": "GET",
      "path": "/api/v1/balance",
      "price": "$0.01",
      "description": "Credited ledger balance of the payer wallet.",
      "auth": "x402"
    },
    {
      "id": "withdraw",
      "method": "POST",
      "path": "/api/v1/withdraw",
      "price": "$0.05",
      "description": "Pay out amount_micro USDC from balance to the payer wallet.",
      "auth": "x402",
      "body_schema": {
        "type": "object",
        "required": ["amount_micro"],
        "properties": {
          "amount_micro": { "type": "integer", "minimum": 500000, "description": "USDC in micro-units (1 USDC = 1_000_000)." }
        }
      }
    }
  ],
  "stake_tiers": {
    "micro":    { "usd": "$0.10",  "micro_usdc": 100000 },
    "standard": { "usd": "$1.00",  "micro_usdc": 1000000 },
    "whale":    { "usd": "$10.00", "micro_usdc": 10000000 }
  },
  "games": {
    "coinflip": { "edge": 0.02,  "payout_on_win": "1.96x" },
    "dice":     { "edge": 0.01,  "payout_formula": "stake * (1 - 0.01) / winChance",
                  "win_chance": { "under": "threshold/100", "over": "(100-threshold)/100" } },
    "roulette": { "edge": 0.027,
                  "payouts": { "red": "2x", "black": "2x", "even": "2x", "odd": "2x",
                               "dozen1": "3x", "dozen2": "3x", "dozen3": "3x", "straight": "36x" } },
    "slots":    { "edge_indicative": 0.045,
                  "symbols": ["cherry", "lemon", "bell", "star", "diamond", "seven"],
                  "paytable": {
                    "3x_seven":   "120x", "3x_diamond": "60x", "3x_star": "30x",
                    "3x_bell":     "20x", "3x_lemon":   "10x", "3x_cherry": "6x",
                    "2x_cherry":   "2x"
                  } }
  },
  "fairness": {
    "model": "commit-reveal",
    "algorithm": "HMAC-SHA256",
    "input": "${client_seed}:${nonce}",
    "commit_endpoint": "https://x402casinos.com/api/v1/seed/commit",
    "reveal_endpoint": "https://x402casinos.com/api/v1/seed/reveal?seed_id={id}",
    "rotation": "every 24h or 10,000 bets"
  },
  "limits": {
    "min_withdrawal_usd": 0.50,
    "per_wallet_daily_cap_usd": 100,
    "global_daily_cap_usd": 1000,
    "max_pending_bets_per_wallet": 20,
    "settlement_timeout_minutes": 10
  },
  "errors": [
    { "http": 400, "code": "payer_address_missing",  "action": "Re-sign the X-PAYMENT envelope and retry." },
    { "http": 400, "code": "BAD_PARAMS",             "action": "Fix the game-specific params and retry." },
    { "http": 400, "code": "invalid_stake",          "action": "Use ?stake=micro|standard|whale." },
    { "http": 402, "code": null,                     "action": "Pay-required handshake — read accepts[] and retry with X-PAYMENT." },
    { "http": 403, "code": "address_blocked",        "action": "OFAC flagged your wallet — stop, do not retry." },
    { "http": 403, "code": "forbidden",              "action": "You queried someone else's bet_id." },
    { "http": 409, "code": "nonce_replay",           "action": "Bump nonce; (client_seed, nonce) already used." },
    { "http": 429, "code": "too_many_pending_bets",  "action": "Wait for settlement of pending bets." },
    { "http": 503, "code": "no_active_seed",         "action": "Casino is rotating seeds — retry in ~1s." },
    { "http": 502, "code": "SUBMIT_FAILED",          "action": "On-chain submit failed; balance refunded — retry." }
  ],
  "examples": {
    "agent_demo_script": "https://github.com/AdrianP-/x402casino/blob/main/scripts/agent-demo.mjs",
    "minimal_curl": [
      "curl -s https://x402casinos.com/api/v1/games | jq",
      "curl -s https://x402casinos.com/api/v1/seed/commit | jq",
      "curl -s -X POST 'https://x402casinos.com/api/v1/games/coinflip?stake=micro' -H 'Content-Type: application/json' -H \"X-PAYMENT: $X402_ENVELOPE_BASE64\" -d '{\"choice\":\"heads\",\"client_seed\":\"deadbeef\",\"nonce\":1}'"
    ]
  },
  "documentation": {
    "skill_md": "https://x402casinos.com/skill.md",
    "html_docs": "https://x402casinos.com/docs",
    "x402_spec": "https://x402.org",
    "eip_3009": "https://eips.ethereum.org/EIPS/eip-3009"
  }
}
