Skip to content

Latest commit

 

History

History
15 lines (8 loc) · 1000 Bytes

File metadata and controls

15 lines (8 loc) · 1000 Bytes

Block Timestamp manipulation

Description:

Contracts often need access to time values to perform certain types of functionality. Values such as block.timestamp, and block.number can give you a sense of the current time or a time delta, however, they are not safe to use for most purposes.

As for block.number, considering the block time on Ethereum is generally about 14 seconds, it's possible to predict the time delta between blocks. However, block times are not constant and are subject to change for a variety of reasons, e.g. fork reorganisations and the difficulty bomb. Due to variable block times, block.number should also not be relied on for precise calculations of time.

Remediation:

Developers should write smart contracts with the notion that block values are not precise, and their use of them can lead to unexpected effects. Alternatively, they may make use of oracles.

References:

https://swcregistry.io/docs/SWC-116