1

uint256

This storage implies that it should give us a max totalSupply of 2^256 - 1. A HUGE number. Note: I only need to store integers, not fractional values for my application.

  1. Is this true?

  2. Is this true for other ERC standards also, or do they differ?

  3. Also, are there other practical implications to consider, perhaps a smaller data structure is used when the 256bits are not needed, so it's better to use a smaller number?

I know this is really three questions, but I think it is better to shoot for one post. Thanks for your time.

  • 1
    1. Yes. 2. Probably yes. 3. This question is too general. Performance-wise (i.e., gas cost and all), it is recommended to use 256-bit slots in your storage data structure, i.e., your contract-level (state) variables. For local variables it doesn't really make much of a difference. But if you know for sure that you're not expecting values above a certain threshold, then you may still wanna consider using uint256, because it will allow you to not worry about overflows. – goodvibration May 27 at 16:19
  • @goodvibration Perfect thanks! – Douglas May 28 at 13:13
1

The native word size of Ethereum virtual machine is uint256. There is no really need to use smaller words, like u128 or u64 for accounting purposes, as there are no real gas efficiency gains. Thus, it is practical to use the uint256 EVM wise.

Note that arguments are RLP packed when communicated to the EVM, so any leading zeroes do not increase the cost, as far as I understand.

Solidity supports uint256 naturally as the default uint.

256-bit numbers are not a problem for good programming languages like Python, where there is native support for BigInts and decimal types. However, some hodgepodge languages like JavaScript need workaround solutions like presenting numbers as strings. But these languages would have the same problems with any monetary units.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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