Skip to content

Blockhash / Block Number Dependence

SAFE-0043 Randomness Checked automatically by the scanner
1

What goes wrong

blockhash is only available for the last 256 blocks (zero otherwise) and is influenceable by validators within a block; using it for randomness or critical timing is unreliable and gameable.

2

How to fix it

the pattern that is safe
// Use VRF; if blockhash unavoidable, require target within 256 blocks and accept bias bounds
blockhash is weak entropy and time-limited.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0043 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs