Skip to main content

Calculate Roll

Derives a provably fair outcome from a server seed, a client seed and a nonce, mapped into a range you choose.

The whole derivation in one node:

combined = serverSeed + ":" + clientSeed + ":" + nonce
hash = SHA256(combined)
result = (first 8 hex digits of hash, as an integer) % (max - min + 1) + min

Both ends of the range are inclusive. If min and max arrive the wrong way round they are swapped rather than producing nonsense.

Combined String Hash is the value to publish as the round's outcome hash, and the value Verify Fairness checks against.

Inputs

Actions

SignalDescription
DoComputes the roll.

General

DataDescription
client seed (string)The player's client seed.
server seed (string)The secret server seed for this round.
nonce (number)The round nonce.
max range (number)Highest value the roll can take, inclusive.
min range (number)Lowest value the roll can take, inclusive.

Outputs

DataDescription
result (number)The roll.
combinedString hash (string)The outcome hash the roll was derived from. Publish this.
SignalDescription
DoneSent when the node has finished, on success and on failure alike.