{
 "route": "fun-random",
 "title": "Verifiable random integers (drand)",
 "method": "GET",
 "price_usdc": 0.001,
 "amount_atomic": "1000",
 "request": {
  "method": "GET",
  "url": "https://utility.agentexchange.work/v1/fun/random?min=1&max=6&n=2",
  "headers": {
   "PAYMENT-SIGNATURE": "<base64 x402 v2 payment payload> (or X-PAYMENT for v1)"
  }
 },
 "captured_at": "2026-10-01T00:25:03.174Z",
 "captured_from": "live upstream, on first request; refreshed after 24 h",
 "response_200": {
  "values": [
   3,
   1
  ],
  "min": 1,
  "max": 6,
  "n": 2,
  "salt": "",
  "drand": {
   "chain_hash": "8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce",
   "public_key": "868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31",
   "scheme": "pedersen-bls-chained",
   "period_s": 30,
   "genesis_time": 1595431050,
   "round": 6512776,
   "round_time": "2026-10-01T00:25:00.000Z",
   "randomness": "f2005dbb6f076d0a2939d2544c5cf580cef66c6c62c186626528f41d209210ce",
   "signature": "84ddaf967aa4dd83d3ad3f8b6e41aab9391d57cd469928179899459337d4ae1a93ffa0aca0cae5e92a2ea0bf8150b7c308b126a78ee77a00cc88daadebbefe07fbfeeb244a06d223385d1402424cf20939982f72cb0cccd9f853ae1473554fd1",
   "previous_signature": "a2dee014e50db915deb9848f405844fa3d5ea76f96990da98d78eb30b49687b491635d3a490726cc72033a1ed0bc80c80a67752b7de4460709aee90631eeaed64fa8390d459c5e0fc39a8a457f55e85f465380a3f861b7af3f0f15f2b361c0a2",
   "url": "https://api.drand.sh/8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce/public/6512776"
  },
  "checks": {
   "randomness_is_sha256_of_signature": true
  },
  "derivation": {
   "method": "rejection sampling over SHA-256",
   "formula": "for value i (0-based) and attempt = 0,1,2,...: h = SHA-256(ASCII(`${randomness}:${salt}:${i}:${attempt}`)) read as a 256-bit big-endian integer; range = max - min + 1; accept the first h < 2^256 - (2^256 mod range); value = min + (h mod range)",
   "verify": "fetch drand.url, check the BLS signature against public_key with any drand client, check randomness = SHA-256(signature), then recompute values with the formula"
  },
  "source": {
   "provider": "drand randomness beacon, League of Entropy (api.drand.sh)",
   "license": "public beacon output"
  },
  "fetched_at": "2026-10-01T00:25:03.163Z",
  "route": "fun-random",
  "price_usdc": 0.001,
  "payment": {
   "transaction": "0x… (settlement transaction hash)",
   "network": "eip155:8453",
   "payer": "0x… (payer address)"
  },
  "request_id": "…"
 },
 "response_402_without_payment": {
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
   "url": "https://utility.agentexchange.work/v1/fun/random?min=1&max=6&n=2",
   "description": "Returns n random integers between min and max derived from the latest public drand randomness beacon round (League of Entropy), with the round number, signature, randomness and the exact SHA-256 derivation so anyone can reproduce and audit the numbers. Call it for dice, raffles, lotteries, sampling or game moves that must be provably unmanipulated. Optional salt makes results distinct per caller.",
   "mimeType": "application/json",
   "serviceName": "drand verifiable random ints",
   "tags": [
    "random",
    "drand",
    "verifiable",
    "dice",
    "games"
   ],
   "iconUrl": "https://utility.agentexchange.work/icon.png"
  },
  "accepts": [
   {
    "scheme": "exact",
    "network": "eip155:8453",
    "amount": "1000",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0xc91cE6291eDC0713ec753BAFBA002506ffb2b95c",
    "maxTimeoutSeconds": 300,
    "extra": {
     "name": "USD Coin",
     "version": "2"
    }
   }
  ],
  "extensions": {
   "bazaar": {
    "info": {
     "input": {
      "type": "http",
      "method": "GET",
      "queryParams": {
       "min": "1",
       "max": "6",
       "n": "2"
      }
     },
     "output": {
      "type": "json",
      "example": {
       "values": [
        4,
        2
       ],
       "min": 1,
       "max": 6,
       "n": 2,
       "salt": "",
       "drand": {
        "chain_hash": "8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce",
        "public_key": "868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31",
        "scheme": "pedersen-bls-chained",
        "period_s": 30,
        "genesis_time": 1595431050,
        "round": 6512750,
        "round_time": "2026-10-01T00:12:00.000Z",
        "randomness": "07940a2473df0f12cb2233eb3422e233eeb43ddddabff8a454a6fff4b88d4159",
        "signature": "98a9c5db6e0a913ce1ff2af62ca71a39ceb1f79302ded4faa356775437ea664d450809145fe00a8c6bedee943a2dfad70254b79734a2a5d71269e9b9f4798ab236fcb3463ad53c244ec302842259a5e99b4097e9345afc282f634ea2ac48e663",
        "previous_signature": "85ebe51c8b933063fdd433a95a3730170c5ac1072ac291ebfe502231e127c6d25179805a219c1999f379c2ee45629c260be71e58395e4944180746f5096d53a661e574e7b2672df188c8548c7d09bf39e84017207b85ce7a8c6516fabd00a891",
        "url": "https://api.drand.sh/8990e7a9aaed2ffed73dbd7092123d6f289930540d7651336225dc172e51b2ce/public/6512750"
       },
       "checks": {
        "randomness_is_sha256_of_signature": true
       },
       "derivation": {
        "method": "rejection sampling over SHA-256"
       },
       "source": {
        "provider": "drand randomness beacon, League of Entropy (api.drand.sh)",
        "license": "public beacon output"
       },
       "fetched_at": "2026-10-01T00:12:14.882Z"
      }
     }
    },
    "schema": {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "type": "object",
     "properties": {
      "input": {
       "type": "object",
       "properties": {
        "type": {
         "type": "string",
         "const": "http"
        },
        "method": {
         "type": "string",
         "enum": [
          "GET",
          "HEAD"
         ]
        },
        "queryParams": {
         "type": "object",
         "properties": {
          "min": {
           "type": "integer",
           "default": 1,
           "description": "smallest value (inclusive)"
          },
          "max": {
           "type": "integer",
           "default": 100,
           "description": "largest value (inclusive)"
          },
          "n": {
           "type": "integer",
           "minimum": 1,
           "maximum": 100,
           "default": 1,
           "description": "how many integers"
          },
          "salt": {
           "type": "string",
           "maxLength": 64,
           "pattern": "^[A-Za-z0-9._:-]*$",
           "description": "optional caller salt mixed into the derivation"
          }
         }
        }
       },
       "required": [
        "type",
        "method"
       ],
       "additionalProperties": false
      },
      "output": {
       "type": "object",
       "properties": {
        "type": {
         "type": "string"
        },
        "example": {
         "type": "object",
         "properties": {
          "values": {
           "type": "array",
           "items": {
            "type": "integer"
           }
          },
          "min": {
           "type": "integer"
          },
          "max": {
           "type": "integer"
          },
          "n": {
           "type": "integer"
          },
          "salt": {
           "type": "string"
          },
          "drand": {
           "type": "object",
           "properties": {
            "chain_hash": {
             "type": "string"
            },
            "public_key": {
             "type": "string"
            },
            "scheme": {
             "type": "string"
            },
            "period_s": {
             "type": "integer"
            },
            "genesis_time": {
             "type": "integer"
            },
            "round": {
             "type": "integer"
            },
            "round_time": {
             "type": "string"
            },
            "randomness": {
             "type": "string"
            },
            "signature": {
             "type": "string"
            },
            "previous_signature": {
             "type": "string"
            },
            "url": {
             "type": "string"
            }
           }
          },
          "checks": {
           "type": "object",
           "properties": {
            "randomness_is_sha256_of_signature": {
             "type": "boolean"
            }
           }
          },
          "derivation": {
           "type": "object",
           "properties": {
            "method": {
             "type": "string"
            }
           }
          },
          "source": {
           "type": "object",
           "properties": {
            "provider": {
             "type": "string"
            },
            "license": {
             "type": "string"
            }
           }
          },
          "fetched_at": {
           "type": "string"
          }
         }
        }
       },
       "required": [
        "type"
       ]
      }
     },
     "required": [
      "input"
     ]
    }
   }
  },
  "message": "Pay $0.001 USDC on Base and retry with PAYMENT-SIGNATURE (v2) or X-PAYMENT (v1).",
  "price": "$0.001",
  "price_usdc": 0.001,
  "amount_atomic": "1000",
  "input_example": "https://utility.agentexchange.work/v1/fun/random?min=1&max=6&n=2",
  "docs": {
   "openapi": "https://utility.agentexchange.work/openapi.json",
   "llms": "https://utility.agentexchange.work/llms.txt",
   "sample": "https://utility.agentexchange.work/samples/fun-random.json",
   "terms": "https://utility.agentexchange.work/terms"
  }
 },
 "docs": "https://utility.agentexchange.work/llms.txt"
}