4

Is there a reason to use the time value as uint256? Is not uint128 enough? UnixTime...

eth
  • 85,679
  • 53
  • 285
  • 406
Tom
  • 75
  • 4

1 Answers1

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