Is there a reason to use the time value as uint256?
Is not uint128 enough?
UnixTime...
Asked
Active
Viewed 1,082 times
4
-
1you mean in solidity? – Tony Dang Sep 11 '18 at 09:26
1 Answers
4
There are 2 parts to consider: reading and storing.
For reading, the EVM is based on a word (storage slot) size of 256 bits, and that's why often it costs less gas when using uint256. Example: Why does uint8 cost more gas than uint256?
But if your contract is storing many timestamps, it can save gas to use uint128 so that you can store 2 of them in 1 storage slot. If you want to save half of the storage, don't forget to test to make sure you are correctly saving 2 uint128 in 1 storage slot.
eth
- 85,679
- 53
- 285
- 406