Random numbers

Returns JSON with cryptographically secure random values: integers in a range, dice rolls, coin flips, UUIDs or hex bytes, from the Workers Web Crypto CSPRNG.

Use this when you need a random number generator, dice rolls, a coin flip, a uuid or random bytes that no one can predict.

Do not use for verifiable on-chain randomness (VRF) or reproducible seeded sequences.

Price: 0.005 USDC per call (x402, eip155:8453). Typical response time: 500 ms (p95).

Call it over HTTP (x402)

POST https://x402-gateway.blackwoodstate8.workers.dev/v1/random. A request without payment gets 402 Payment Required with the PAYMENT-REQUIRED header; any x402 client signs an EIP-3009 authorization and retries with PAYMENT-SIGNATURE (or X-PAYMENT). Invalid input is answered with 400 and not charged.

curl -i -X POST https://x402-gateway.blackwoodstate8.workers.dev/v1/random -H 'content-type: application/json' -d '{"kind":"dice","count":2,"sides":6}'
Pay to0x60DdC7528FBEe16279C3ae7aC3647989CD714A11
Asset0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (USDC)
Amount5000 atomic units (0.005 USDC)
Authorization window60 s

Call it over MCP

Streamable HTTP at https://x402-gateway.blackwoodstate8.workers.dev/mcp, tool blackwood_random_generate. Payment goes in _meta["x402/payment"]; without it the tool returns the payment requirements.

Input

FieldTypeMeaning
kindstringinteger (count values between min and max), dice (count rolls of a die with sides faces), coin (count flips), uuid (count UUID v4) or bytes (length random bytes as hex)
count (optional)integerHow many values (1-100, default 1); ignored for bytes
min (optional)integerinteger: lowest value, inclusive (default 1)
max (optional)integerinteger: highest value, inclusive (default 100)
sides (optional)integerdice: faces of the die (default 6)
length (optional)integerbytes: how many random bytes (1-256, default 32)

Example:

{
  "kind": "dice",
  "count": 2,
  "sides": 6
}

Output

Real example:

{
  "kind": "dice",
  "values": [
    4,
    1
  ],
  "sum": 5,
  "generatedAt": "2026-10-17T16:48:06.750Z",
  "source": "crypto.getRandomValues (Cloudflare Workers CSPRNG)"
}
JSON Schema
{
  "type": "object",
  "properties": {
    "kind": {
      "type": "string"
    },
    "values": {
      "type": "array",
      "items": {
        "type": [
          "number",
          "string"
        ]
      }
    },
    "sum": {
      "type": [
        "number",
        "null"
      ]
    },
    "generatedAt": {
      "type": "string"
    },
    "source": {
      "type": "string"
    }
  },
  "required": [
    "kind",
    "values",
    "sum",
    "generatedAt",
    "source"
  ],
  "additionalProperties": false
}

More

Free schema and example: GET https://x402-gateway.blackwoodstate8.workers.dev/v1/random. OpenAPI 3.1 · llms.txt · All services