A

Animica · Random INT

by Animica

POSTBaseanimica:1

$0.0058

per call · USD Coin on Base

Uniform integers in [min, max] derived from ONE verified randomness draw by rejection sampling (never modulo bias) — up to 1000 per request. The response carries the raw draw, the node's source/health/attestation and the exact rule, so you can recompute every integer offline.

Endpoint

POST https://animica.dev/x402/random/int

3

Calls / 30d

1

Unique payers / 30d

Aug 22

Last called

exact

Payment scheme

Call this service

TypeScript · @x402/fetch
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const fetchWithPay = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPay("https://animica.dev/x402/random/int", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "count": 3,
    "max": 6,
    "min": 1
  }),
});
const data = await res.json();
cURL
curl -X POST \
  "https://animica.dev/x402/random/int" \
  -H "Content-Type: application/json" \
  -d '{"count":3,"max":6,"min":1}' \
  -H "X-PAYMENT: <signed x402 payment>"

Example response

{
  "attestation": {
    "alg": "ed25519",
    "attested": false,
    "backend": "software",
    "digest_hex": "14a2636cf09e18539ab6ed62de65af350c2f6014d269b74d127fc1604c7aa68a",
    "public_key_hex": "8a2228f4bde8f72964a7ff4aa759f24932ae1cccd9462ad94ca6e508d6b87a64",
    "signature_hex": "bee4d32ee31dd92b07f1eee3113ed722c3c96c5fae98c509bcca8f66a5ceaff3eb4a6cd41cd97fc32deebdeeab18b4affea467549dd4ef387ddbdae6d415e900"
  },
  "bytes": 32,
  "derivation": {
    "algorithm": "uniform-int-rejection-sampling",
    "domain": "animica/qrng/public/v1",
    "entropy_hex": "8e8d85d9c03247ffdff7b3db1c917b7a0e97a569e8cf098071dd91cc9121ae55",
    "kind": "range",
    "recompute": {
      "beacon_hex": "8e8d85d9c03247ffdff7b3db1c917b7a0e97a569e8cf098071dd91cc9121ae55",
      "kind": "range",
      "output": [
        5,
        1,
        2
      ],
      "params": {
        "count": 3,
        "hi": 6,
        "lo": 1
      },
      "request_id": "",
      "round_id": 0
    },
    "request_id": "",
    "rules": {
      "seed": "seed = sha3_256(\"animica/qrng/public/v1\" || \"|k:\" || kind || \"|r:\" || request_id || \"|b:\" || bytes(randomness))",
      "stream": "stream = sha3_256(seed || be8(counter)) for counter = 0,1,2,… concatenated; consumed left to right, never reused",
      "uniform_int": "randbelow(n): k = floor((bitlen(n)+7)/8)+1 bytes per attempt, read big-endian as x; limit = 2^(8k); accept when x < limit - (limit mod n); value = x mod n. Rejected attempts still consume their k bytes. n <= 1 consumes nothing and returns 0. This is rejection sampling — plain \"x mod n\" would bias small values."
    },
    "seed_hex": "5fb4cc0e8007c201060453ee9b7cacb38444d32d76d423c61e601117fadd3068",
    "steps": [
      "seed the DRNG with kind=\"range\" and your request_id over the raw randomness above",
      "for i = 0..2: ints[i] = 1 + randbelow(6)"
    ],
    "stream_bytes_consumed": 6,
    "verifier": {
      "api": "AnimicaBeacon.drngSeed(entropy, kind, request_id) + AnimicaBeacon.QDRNG reproduce the stream; AnimicaBeacon.verifyResult(derivation.recompute) === true whenever `recompute` is present",
      "file": "randomness/beacon_api/static/verify.js (Animica repo, github.com/animicaorg) — zero-dependency, runs in Node and the browser",
      "note": "verify.js calls the seed material `beacon` because it was written for beacon rounds. This product is NOT a beacon round: the seed material is the raw `randomness` bytes above, which the node signed (see `verification`)."
    }
  },
  "encoding": "hex",
  "health": {
    "min_entropy_per_byte": 7.8216,
    "passed": true
  },
  "product": "random_int",
  "randomness": "8e8d85d9c03247ffdff7b3db1c917b7a0e97a569e8cf098071dd91cc9121ae55",
  "result": {
    "count": 3,
    "ints": [
      5,
      1,
      2
    ],
    "max": 6,
    "min": 1
  },
  "source": {
    "attested": false,
    "device_path": null,
    "is_hardware": false,
    "is_quantum": false,
    "model": "os.urandom CSPRNG",
    "name": "software-fallback",
    "notes": "non-attested fallback for testing/degraded mode",
    "vendor": "os"
  },
  "verification": {
    "attested": false,
    "method": "signed-digest-attestation",
    "rules": [
      "attestation.digest_hex == sha3_256(bytes(randomness))",
      "ed25519_verify(pubkey=attestation.public_key_hex, message=raw_bytes(attestation.digest_hex), signature=attestation.signature_hex)"
    ],
    "trust_model": "signed by the serving node, not client-recomputable: you trust the node's entropy source, then verify it signed exactly these bytes. Check health.passed and attestation.attested before relying on it.",
    "verifier": "randomness/beacon_api/static/verify.js in the animica repo (github.com/animicaorg) — dependency-free Node module exporting sha3_256; pair with any ed25519 verifier"
  }
}

Payment details

Pay to0x5d17c40fd6b119dc6006c4ab3c20a917fcab2acd
AssetUSD Coin · 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
NetworksBase, animica:1
Schemesexact

Is this your API?

Pin it to the top of Games & Fun and the homepage with a featured placement.

Get featured →

More from Animica & similar services