Random number generation
Random number generation for Tact smart contracts.
random
Generates and returns a new pseudo-random unsigned Int
value x
in the provided semi-closed interval: min
x
max
or min
x
max
, if both min
and max
are negative. Note, that max
value is never included in the interval.
Usage examples:
randomInt
Generates and returns a new pseudo-random unsigned -bit Int
value x
.
The algorithm works as follows: if r
is the old value of the random seed considered a -byte array (by constructing the big-endian representation of an unsigned -bit Int
), then its sha512(r)
is computed. The first bytes of this hash are stored as the new value r'
of the random seed, and the remaining bytes are returned as the next random value x
.
Usage example: