Why use uint256 when much smaller ints will suffice? #1173
-
|
Hello- Newby question, I am following Patrick's excellent course, but I have seen a number of examples where he used uint256 variables in a place where a much smaller variable, i.e. uint 16 or 32 would more than suffice for the possible range of data. For example, the number of different tokens types that might be supported by a dApp. Is there any point to using smaller variable types? I would guess that larger variables result in larger contract storage, which I THINK results in higher gas fees. Am I correct, or are the savings negligible? Thanks! Still learning... Jim |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
the answer will be fewer gas costs, however, I have seen some examples where people tried to create test codes and measure the consumed gas for comparison. The difference will become only substantial when considering your contract will be called millions of times. |
Beta Was this translation helpful? Give feedback.
the answer will be fewer gas costs, however, I have seen some examples where people tried to create test codes and measure the consumed gas for comparison. The difference will become only substantial when considering your contract will be called millions of times.