{
  "openapi": "3.1.0",
  "info": {
    "title": "Block Lottos API",
    "description": "Public API for Block Lottos, including Polygon Fortune Ledger and Base Future Ledger lottery endpoints, live jackpot data, site stats, and the advertising submission system. No API key required.",
    "version": "1.0.0",
    "contact": {
      "name": "Block Lottos Support",
      "email": "support@blocklottos.com",
      "url": "https://blocklottos.com/contact"
    },
    "license": {
      "name": "Public",
      "url": "https://blocklottos.com/terms"
    }
  },
  "servers": [
    {
      "url": "https://blocklottos.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/jackpot.php": {
      "get": {
        "operationId": "getJackpot",
        "summary": "Get current jackpot",
        "description": "Returns the live jackpot amount for the selected lottery game. No auth required. Cached for 60 seconds. Supports ?chain=polygon or ?chain=base.",
        "tags": [
          "Lottery"
        ],
        "responses": {
          "200": {
            "description": "Current jackpot amount",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jackpot_pol": {
                      "type": "number",
                      "description": "Jackpot amount in the selected chain currency",
                      "example": 142.5
                    },
                    "jackpot_wei": {
                      "type": "string",
                      "description": "Jackpot amount in wei (string to preserve precision)",
                      "example": "142500000000000000000"
                    },
                    "contract": {
                      "type": "string",
                      "description": "Smart contract address",
                      "example": "0x07F62Ff6697eD9b475FEed9dc90a5A157936839c"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "error"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          }
        ]
      }
    },
    "/api/stats.php": {
      "get": {
        "operationId": "getStats",
        "summary": "Get site stats",
        "description": "Returns live stats for the selected lottery game, including draw number, jackpot, and next draw timestamp. Supports ?chain=polygon or ?chain=base.",
        "tags": [
          "Lottery"
        ],
        "responses": {
          "200": {
            "description": "Site statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "draw_number": {
                      "type": "integer",
                      "description": "Upcoming draw number",
                      "example": 8
                    },
                    "jackpot_pol": {
                      "type": "number",
                      "description": "Current jackpot in the selected chain currency",
                      "example": 142.5
                    },
                    "next_draw_timestamp": {
                      "type": "integer",
                      "description": "Unix timestamp of next draw (Saturdays 15:00 UTC)",
                      "example": 1745589600
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "error"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          }
        ]
      }
    },
    "/api/ads/sizes": {
      "get": {
        "operationId": "getAdSizes",
        "summary": "Get available ad sizes and pricing",
        "description": "Returns all available banner sizes with dimensions, pricing for 7/14/30 day durations, submission fee, and any active discounts. Rate limit: 2 requests/min/IP.",
        "tags": [
          "Advertising"
        ],
        "responses": {
          "200": {
            "description": "Available ad sizes and pricing",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sizes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "example": "300x250"
                          },
                          "width": {
                            "type": "integer",
                            "example": 300
                          },
                          "height": {
                            "type": "integer",
                            "example": 250
                          },
                          "label": {
                            "type": "string"
                          },
                          "price_7d": {
                            "type": "number",
                            "description": "7-day placement price in USDC",
                            "example": 85
                          },
                          "price_14d": {
                            "type": "number",
                            "description": "14-day placement price in USDC",
                            "example": 140
                          },
                          "price_30d": {
                            "type": "number",
                            "description": "30-day placement price in USDC",
                            "example": 250
                          },
                          "discount_pct": {
                            "type": "number",
                            "example": 0
                          },
                          "discount_expires": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "discounted_price_7d": {
                            "type": "number",
                            "description": "Discounted 7-day price in USDC"
                          },
                          "discounted_price_14d": {
                            "type": "number",
                            "description": "Discounted 14-day price in USDC"
                          },
                          "discounted_price_30d": {
                            "type": "number",
                            "description": "Discounted 30-day price in USDC"
                          }
                        }
                      }
                    },
                    "submit_fee": {
                      "type": "number",
                      "description": "Non-refundable submission quote fee in USDC",
                      "example": 1
                    },
                    "currency": {
                      "type": "string",
                      "example": "USDC"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/ads/submit": {
      "post": {
        "operationId": "submitAd",
        "summary": "Submit an ad (quote-first flow, step 1)",
        "description": "Submit ad details and an image to get a payment quote. Returns a quote_id and an unsigned USDC transfer transaction. The caller signs and broadcasts the transaction from their Web3 wallet, then calls POST /api/ads/submit/pay to finalise. Rate limit: 10 requests/min/IP.",
        "tags": [
          "Advertising"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "image",
                  "size_id",
                  "target_url",
                  "wallet_address"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "Banner image file. Dimensions must exactly match size_id."
                  },
                  "size_id": {
                    "type": "string",
                    "description": "Ad size ID from /api/ads/sizes",
                    "example": "300x250"
                  },
                  "target_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "URL the ad should link to",
                    "example": "https://example.com"
                  },
                  "wallet_address": {
                    "type": "string",
                    "description": "EVM wallet address that will make payment",
                    "example": "0x000000000000000000000000000000000000dEaD"
                  },
                  "network": {
                    "type": "string",
                    "description": "USDC payment network",
                    "enum": [
                      "polygon",
                      "base",
                      "avalanche",
                      "ethereum",
                      "arbitrum",
                      "optimism",
                      "bnb"
                    ],
                    "default": "polygon"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote generated - sign and broadcast the transaction, then call /api/ads/submit/pay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote_id": {
                      "type": "string",
                      "description": "Use this in the /api/ads/submit/pay call",
                      "example": "sq_abc123"
                    },
                    "status": {
                      "type": "string",
                      "example": "awaiting_payment"
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "payment": {
                      "type": "object",
                      "description": "Unsigned USDC transfer transaction and payment metadata"
                    },
                    "next_step": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/ads/submit/pay": {
      "post": {
        "operationId": "confirmAdSubmitPayment",
        "summary": "Confirm ad payment (quote-first flow, step 2)",
        "description": "After broadcasting the USDC payment transaction, call this endpoint with quote_id and transaction hash to finalise the submission. The system verifies the transaction on-chain. Accepts application/json or form-encoded bodies.",
        "tags": [
          "Advertising"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "tx_hash"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "description": "Quote ID from POST /api/ads/submit",
                    "example": "q_123456"
                  },
                  "tx_hash": {
                    "type": "string",
                    "description": "Transaction hash of your USDC payment on the selected network",
                    "example": "0xabc123..."
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "tx_hash"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "description": "Quote ID from POST /api/ads/submit",
                    "example": "q_123456"
                  },
                  "tx_hash": {
                    "type": "string",
                    "description": "Transaction hash of your USDC payment on the selected network",
                    "example": "0xabc123..."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Submission confirmed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "submission_id": {
                      "type": "string",
                      "description": "Use this to check status",
                      "example": "ad_42"
                    },
                    "status": {
                      "type": "string",
                      "example": "pending_review"
                    },
                    "message": {
                      "type": "string",
                      "example": "Ad submitted successfully and is pending review."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid quote_id or tx_hash"
          },
          "402": {
            "description": "Payment not verified on-chain"
          }
        }
      }
    },
    "/api/ads/status/{submission_id}": {
      "get": {
        "operationId": "getAdStatus",
        "summary": "Check ad submission status",
        "description": "Returns the current status of a submitted ad. Rate limit: 2 requests/min/IP.",
        "tags": [
          "Advertising"
        ],
        "parameters": [
          {
            "name": "submission_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Submission ID returned by /api/ads/submit/pay (e.g. ad_42)",
            "example": "ad_42"
          }
        ],
        "responses": {
          "200": {
            "description": "Ad status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "submission_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending_review",
                        "approved",
                        "rejected",
                        "active",
                        "expired"
                      ],
                      "description": "Current status of the ad"
                    },
                    "banner_size": {
                      "type": "string"
                    },
                    "target_url": {
                      "type": "string"
                    },
                    "submitted_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "reviewed_at": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Submission not found"
          }
        }
      }
    },
    "/api/ads/wallet/{wallet_address}": {
      "get": {
        "operationId": "getAdsByWallet",
        "summary": "Get all ads for a wallet",
        "description": "Returns all ad submissions associated with an EVM wallet address. Useful for bots to discover their submission IDs and track statuses. Rate limit: 2 requests/min/IP.",
        "tags": [
          "Advertising"
        ],
        "parameters": [
          {
            "name": "wallet_address",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "EVM wallet address (0x...)",
            "example": "0xYourWalletAddress"
          }
        ],
        "responses": {
          "200": {
            "description": "List of ads for this wallet",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet": {
                      "type": "string"
                    },
                    "ads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "submission_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "banner_size": {
                            "type": "string"
                          },
                          "target_url": {
                            "type": "string"
                          },
                          "submitted_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "expires_at": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid wallet address"
          }
        }
      }
    },
    "/api/lottery/build-ticket-tx": {
      "post": {
        "operationId": "buildLotteryTicketTx",
        "summary": "Build an unsigned lottery ticket transaction",
        "description": "Builds transaction data for buying a lottery ticket. Polygon returns a native POL value transaction. Base returns a USDC approval transaction plus a zero-value ticket purchase transaction.",
        "tags": [
          "Lottery"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet_address",
                  "numbers"
                ],
                "properties": {
                  "chain": {
                    "type": "string",
                    "enum": [
                      "polygon",
                      "base"
                    ],
                    "default": "polygon"
                  },
                  "wallet_address": {
                    "type": "string",
                    "example": "0x000000000000000000000000000000000000dEaD"
                  },
                  "numbers": {
                    "type": "array",
                    "items": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 49
                    },
                    "minItems": 6,
                    "maxItems": 6,
                    "example": [
                      1,
                      2,
                      3,
                      4,
                      5,
                      6
                    ]
                  },
                  "referral_id": {
                    "type": "string",
                    "description": "Optional Base referral ID as 0x bytes32 or a short code up to 32 characters."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned transaction payloads ready for wallet signing"
          },
          "400": {
            "description": "Invalid input"
          },
          "503": {
            "description": "RPC unavailable"
          }
        }
      }
    },
    "/api/lottery/tickets/{wallet}": {
      "get": {
        "operationId": "getLotteryTickets",
        "summary": "Get wallet tickets for the active draw",
        "description": "Returns tickets purchased by a wallet for the active draw on Polygon or Base.",
        "tags": [
          "Lottery"
        ],
        "parameters": [
          {
            "name": "wallet",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          }
        ],
        "responses": {
          "200": {
            "description": "Wallet ticket list"
          },
          "400": {
            "description": "Invalid wallet"
          },
          "503": {
            "description": "RPC unavailable"
          }
        }
      }
    },
    "/api/lottery/draw-history": {
      "get": {
        "operationId": "getLotteryDrawHistory",
        "summary": "Get lottery draw history",
        "description": "Returns recent completed on-chain draw results from Polygon or Base. If no on-chain draw has completed yet, returns published public draw results from the website result JSON files.",
        "tags": [
          "Lottery"
        ],
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          },
          {
            "name": "draw_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Draw history or published public draw results",
            "content": {
              "application/json": {
                "examples": {
                  "polygonLatest": {
                    "summary": "Polygon latest published draw",
                    "value": {
                      "status": "ok",
                      "chain": "polygon",
                      "network": "Polygon Mainnet",
                      "draws": [
                        {
                          "draw_id": 0,
                          "winning_numbers": [
                            3,
                            9,
                            17,
                            28,
                            36,
                            44
                          ],
                          "jackpot": 0,
                          "jackpot_units": "0",
                          "currency": "POL",
                          "jackpot_won": false,
                          "rolled_over": true,
                          "prize_per_winner": 0,
                          "prize_per_winner_units": "0",
                          "draw_timestamp": 1780174500,
                          "draw_date": "2026-05-30",
                          "status": "preview",
                          "note": "One-time Polygon preview numbers generated for the current site display. Not submitted on chain because Polygon v1.3 first draw opens at Saturday 15:00 UTC on 2026-06-06."
                        }
                      ],
                      "current_draw_id": 0,
                      "source": "local_public_results",
                      "message": "Showing published draw results"
                    }
                  },
                  "baseLatest": {
                    "summary": "Base latest published draw",
                    "value": {
                      "status": "ok",
                      "chain": "base",
                      "network": "Base Mainnet",
                      "draws": [
                        {
                          "draw_id": 0,
                          "winning_numbers": [
                            1,
                            12,
                            14,
                            16,
                            31,
                            32
                          ],
                          "jackpot": 0,
                          "jackpot_units": "0",
                          "currency": "USDC",
                          "jackpot_won": false,
                          "rolled_over": true,
                          "prize_per_winner": 0,
                          "prize_per_winner_units": "0",
                          "draw_timestamp": 1780169863,
                          "draw_date": "2026-05-30",
                          "status": "preview",
                          "note": "One-time Base preview numbers generated by the server cron runner. Not submitted on chain because the first Base v1.3 draw opens at Saturday 16:00 UTC on 2026-06-06."
                        }
                      ],
                      "current_draw_id": 0,
                      "source": "local_public_results",
                      "message": "Showing published draw results"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "RPC unavailable"
          }
        },
        "externalDocs": {
          "description": "Public result JSON files",
          "url": "https://blocklottos.com/data/draws/latest.json"
        }
      }
    },
    "/api/lottery/draw-proof": {
      "get": {
        "operationId": "getLotteryDrawProof",
        "summary": "Get public draw proof",
        "description": "Returns the public cutoff commitment or completed draw proof for Polygon Fortune Ledger or Base Future Ledger. During cutoff, winning numbers and the secret seed are hidden. After draw runtime, the proof includes the revealed seed, chain anchor block, final seed, and winning numbers.",
        "tags": [
          "Lottery"
        ],
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          },
          {
            "name": "draw_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "Specific draw ID. Omit for the latest public proof."
          }
        ],
        "responses": {
          "200": {
            "description": "Public cutoff or completed draw proof"
          },
          "404": {
            "description": "No public proof is available yet"
          }
        },
        "externalDocs": {
          "description": "Human-readable proof page",
          "url": "https://blocklottos.com/draw-proof"
        }
      }
    },
    "/api/lottery/check-prizes/{wallet}": {
      "get": {
        "operationId": "checkLotteryPrizes",
        "summary": "Check outstanding failed prize payout for a wallet",
        "description": "Checks whether a wallet has an outstanding failed prize payout on Polygon or Base. Normal winning payouts are automatic; this endpoint reports only amounts that need owner retry through retrySendPrize().",
        "tags": [
          "Lottery"
        ],
        "parameters": [
          {
            "name": "wallet",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          }
        ],
        "responses": {
          "200": {
            "description": "Outstanding failed-prize payout status"
          },
          "400": {
            "description": "Invalid wallet"
          },
          "503": {
            "description": "RPC unavailable"
          }
        }
      }
    },
    "/api/ads/activate": {
      "post": {
        "operationId": "requestAdActivationQuote",
        "summary": "Request an ad activation quote",
        "description": "Request an activation quote for an approved ad. Returns current duration pricing and an unsigned USDC transfer transaction. Accepts application/json or form-encoded bodies. Rate limit: 10 requests/min/IP.",
        "tags": [
          "Advertising"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "submission_id",
                  "duration",
                  "wallet_address"
                ],
                "properties": {
                  "submission_id": {
                    "type": "string",
                    "example": "ad_42"
                  },
                  "duration": {
                    "type": "string",
                    "enum": [
                      "7d",
                      "14d",
                      "30d"
                    ]
                  },
                  "wallet_address": {
                    "type": "string",
                    "description": "EVM wallet address that will make payment",
                    "example": "0x000000000000000000000000000000000000dEaD"
                  },
                  "network": {
                    "type": "string",
                    "enum": [
                      "polygon",
                      "base",
                      "avalanche",
                      "ethereum",
                      "arbitrum",
                      "optimism",
                      "bnb"
                    ],
                    "default": "polygon"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "submission_id",
                  "duration",
                  "wallet_address"
                ],
                "properties": {
                  "submission_id": {
                    "type": "string"
                  },
                  "duration": {
                    "type": "string"
                  },
                  "wallet_address": {
                    "type": "string"
                  },
                  "network": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Activation quote generated"
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Submission not found"
          },
          "409": {
            "description": "Ad is not approved"
          }
        }
      }
    },
    "/api/ads/activate/pay": {
      "post": {
        "operationId": "confirmAdActivationPayment",
        "summary": "Confirm ad activation payment",
        "description": "After broadcasting the USDC activation payment transaction, call this endpoint with quote_id and transaction hash. The system verifies payment on-chain before activating the ad. Accepts application/json or form-encoded bodies. Rate limit: 10 requests/min/IP.",
        "tags": [
          "Advertising"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "tx_hash"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "example": "aq_xyz789"
                  },
                  "tx_hash": {
                    "type": "string",
                    "description": "Transaction hash of your USDC payment on the selected network",
                    "example": "0xabc123..."
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "quote_id",
                  "tx_hash"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "example": "aq_xyz789"
                  },
                  "tx_hash": {
                    "type": "string",
                    "description": "Transaction hash of your USDC payment on the selected network",
                    "example": "0xabc123..."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ad activated"
          },
          "400": {
            "description": "Invalid quote_id or tx_hash"
          },
          "402": {
            "description": "Payment not verified on-chain"
          },
          "404": {
            "description": "Quote or ad not found"
          },
          "409": {
            "description": "Quote already used or ad state changed"
          }
        }
      }
    },
    "/api/lottery/jackpot": {
      "get": {
        "operationId": "getLotteryJackpotAlias",
        "summary": "Get current jackpot",
        "description": "Returns the live jackpot amount for the selected lottery game. No auth required. Cached for 60 seconds. Supports ?chain=polygon or ?chain=base. Alias of /api/jackpot.php for clients that prefer the /api/lottery namespace.",
        "tags": [
          "Lottery"
        ],
        "responses": {
          "200": {
            "description": "Current jackpot amount",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jackpot_pol": {
                      "type": "number",
                      "description": "Jackpot amount in the selected chain currency",
                      "example": 142.5
                    },
                    "jackpot_wei": {
                      "type": "string",
                      "description": "Jackpot amount in wei (string to preserve precision)",
                      "example": "142500000000000000000"
                    },
                    "contract": {
                      "type": "string",
                      "description": "Smart contract address",
                      "example": "0x07F62Ff6697eD9b475FEed9dc90a5A157936839c"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "error"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          }
        ]
      }
    },
    "/api/lottery/stats": {
      "get": {
        "operationId": "getLotteryStatsAlias",
        "summary": "Get site stats",
        "description": "Returns live stats for the selected lottery game, including draw number, jackpot, and next draw timestamp. Supports ?chain=polygon or ?chain=base. Alias of /api/stats.php for clients that prefer the /api/lottery namespace.",
        "tags": [
          "Lottery"
        ],
        "responses": {
          "200": {
            "description": "Site statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "draw_number": {
                      "type": "integer",
                      "description": "Upcoming draw number",
                      "example": 8
                    },
                    "jackpot_pol": {
                      "type": "number",
                      "description": "Current jackpot in the selected chain currency",
                      "example": 142.5
                    },
                    "next_draw_timestamp": {
                      "type": "integer",
                      "description": "Unix timestamp of next draw (Saturdays 15:00 UTC)",
                      "example": 1745589600
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok",
                        "error"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "polygon",
                "base"
              ],
              "default": "polygon"
            },
            "description": "Lottery chain to query. Use polygon for Polygon Fortune Ledger or base for Base Future Ledger."
          }
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Lottery",
      "description": "Lottery data and transaction builders for Polygon Fortune Ledger and Base Future Ledger"
    },
    {
      "name": "Advertising",
      "description": "Display advertising API - submit, manage, and track ads on Block Lottos."
    }
  ],
  "externalDocs": {
    "description": "Full API documentation",
    "url": "https://blocklottos.com/api-docs"
  },
  "x-blocklottos-active-contracts": {
    "polygon": {
      "name": "Polygon Fortune Ledger",
      "chain_id": 137,
      "contract": "0x07F62Ff6697eD9b475FEed9dc90a5A157936839c",
      "ticket_price": "10 POL",
      "ticket_token": "native POL",
      "draw_time_utc": "Saturday 15:00"
    },
    "base": {
      "name": "Base Future Ledger",
      "chain_id": 8453,
      "contract": "0xe5a9cF597ec65523BD71a8433B620eB1F3Eb0d0a",
      "ticket_price": "1 USDC",
      "ticket_token": "official Base USDC",
      "ticket_token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "draw_time_utc": "Saturday 16:00"
    }
  }
}
