Is the length (number of digits) of the number generated by ChainLink VRF always the same?

My contract executes modulus operations to get subnumbers of the big number generated, so if it's not the same length it won't work, can't find the answer anywhere.

1 Answer 1

The Chainlink VRF will always return a uint256 length number.

This means it can be anything from 0 to 2**256 – 1

A modulus will still work no matter the length of the number anyway.

100000 % 2 = 0
1 % 2 = 1

100000 and 1 are different lengths, but the operation works the same.

  • I love this attribute of clock arithmetics. With the modulus operator, you could turn the random number re turned from Chainlink VRF into a number within a (0, n-1) range. Jun 26, 2021 at 9:26
  • You could also shift the range as follows. e.g., x % n + m would yield random numbers within the range (m, n+m-1). Jun 26, 2021 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.