Hardhat Network Forking: Deterministic Block Timestamp Constraint
0 reputation · 02 Feb 2022, 14:42 UTC
Feature Overview
Hardhat’s --fork flag captures the latest block from a live network, including its block.timestamp. This value is used as the starting point for all forked test runs.
Missing Constraint
When multiple forks or parallel test executions occur, the forked block’s timestamp is taken directly from the source chain’s most recent block. Hardhat does not expose a configuration option to set a fixed or deterministic timestamp for the forked state. Consequently, contracts that depend on block.timestamp—such as auctions, vesting schedules, or rate‑limit logic—can behave nondeterministically in forked environments.
Unresolved Decision
Developers currently rely on manual overrides (e.g., JSON‑RPC evm_setTime) or console adjustments, but these are not integrated into the fork configuration. The lack of an official flag leaves a design gap in Hardhat’s documentation.
Key Questions
- Is there a planned Hardhat flag to set a deterministic timestamp for forked networks?
- What is the recommended approach to reliably control
block.timestampin forked tests without manual overrides? - Will future releases introduce a built‑in mechanism for deterministic fork timestamps, and how will it affect existing test suites?