I'd like to configure my Hardhat node to start at a specific timestamp t, where t is less than the current timestamp Tc. The goal is to replay past mainnet transactions locally by setting the exact timestamp, and potentially even the block number, at which these transactions occurred.
While Hardhat's time.increaseTo method allows altering the time to a time later than the current unix time, it doesn't offer the capability to specify an initial timestamp in the past. For example, if I want to replay transactions A, B, and C, which occurred at times 1000, 1003, and 1008 respectively, and the current time is 1_000_000
, I can:
- Replay transaction A.
- Use
time.increaseTo(1_000_003)
to set the time before replaying transaction B. - Use
time.increaseTo(1_000_008)
to set the time before replaying transaction C.
But this approach is not flexible enough for scenarios where having control over the exact timestamp and block number is crucial. Is there a way to set these properties when starting a local Hardhat node?