1

I'm working with time-dependent logic. In order to test it, a specific transaction needs to be mined at a specific time given in seconds.

In Hardhat it is possible to increase the block timestamp to the desired value. However I can't get the transaction to appear in that block (it's a few seconds off). Is there a way to configure Hardhat to include the transaction in a block with the exact specified timestamp?

1 Answer 1

0

You're always going to have some delay as the network logs your tx/contract. The best you can do is approximate this delay, and set your desired block timestamp including tolerance to trigger the tx.

1
  • I see. However since the Hardhat network is used exclusively for testing, I assume there is a way to set the block timestamp to the desired value. Is this not a possibility?
    – leotron
    Dec 9, 2022 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.