Why is there a need to specify uint8 or uint256, why isn't uint enough? isn't this all about optimizing gas costs, and I assume the solidity optimizer will do this.

1 Answer 1


Unfortunately, you are responsible for best optimizing your code so it uses the corresponding size according to your needs.

One thing to note is uint (or int) is just an alias for uint256 / int256.

It's your own decision whether to use uint8 or uint256 (or whatever size) depending how big or small you expect the number in question to be.

You could use the biggest possible size and later on start optimizing your code accordingly.

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.