In the statement:

uint256 x = uint256(keccak256(abi.encodePacked(valuesToEncode)));

What’s the minimum and maximum possible values for x?

When I looped random valuesToEncode the smallest resulting value for x had 73 digits and the largest had 78 digits.

1 Answer 1


In theory, it's 0 and 2**256-1, respectively.

  • Thanks, but those are the min and max values for uint256, but I don’t think keccak256 will return a value that casts to a uint256 of 0.
    – rbinnun
    Commented Jan 12, 2022 at 14:30
  • 1
    That's why I said in theory. I think no one actually knows what the practical limits are, but if you don't believe in the occurance of hash collision, by enumerating all 2**256-1 integers with some arbitrary prefix or postfix, there should be a value producing 0 or 2**256-1. Just guessing though.
    – Maxareo
    Commented Jan 12, 2022 at 15:55

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.