Verifiable dice roll from a seed, with a re-derivable transcript

$0.005 USDC per call · Business, finance and compliance · POST /api/v1/dice-roll · Id dice-roll

Rolls dice notation (for example 4d6kh3+2) from a caller seed with a documented SHA-256 counter-mode stream and returns every die, the kept/dropped marks and a full draw transcript, for agents and referees that need a roll anyone can re-derive. Optionally checks a claimed total or claimed faces against the re-derived roll. Does NOT provide unpredictable randomness: the seed is public input, so anyone who knows it knows the outcome; do not use it for gambling or security. Exploding dice, rerolls, success counting, d% and fudge dice return unsupported.

What you get

Disputed rolls end with a hash-checkable transcript instead of an argument.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/dice-roll. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/dice-roll \
  -H 'content-type: application/json' \
  -d '{"notation":"4d6kh3+2","seed":"campaign-7/session-3/roll-12"}'

Input

FieldTypeRequiredDescription
notationstring; length 1..200yesDice notation: terms of NdM (N 1-100, M 2-1000) or integers joined by + and -; optional kh/kl/dh/dl with a count on a group. At most 20 groups and 1000 dice.
seedstring; length 1..200yesCaller seed string. Public: the outcome is a pure function of notation and seed.
expectTotalinteger; -100000000..100000000noOptional claimed total to verify.
expectRollsarray<integer; 1..1000>; max 1000 itemsnoOptional claimed faces in notation order, before keep/drop marks.
includeTranscriptbooleannoDefault true. False drops blocks and draws (the transcript digest stays).

Example request body

{
  "notation": "4d6kh3+2",
  "seed": "campaign-7/session-3/roll-12"
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
notationstring; length 0..200noCanonical notation (or the input when unsupported).
totalintegerno
rollsarray<integer>; max 1000 itemsnoEvery die face, in notation order.
groupsarray<object>no
constantsintegernoSum of the integer terms.
rejectedWordsintegernoWords discarded by rejection sampling.
transcriptSha256stringnoSHA-256 of the JCS-canonical draws array.
blocksarray<object>no
drawsarray<object>no
algorithmstringnoThe exact stream and sampling algorithm.
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the creative-games-kit package.

Machine-readable