3

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

  • 1
    you mean in solidity? – Ha ĐANG Sep 11 '18 at 9:26
2

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.

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.