Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

can we freeze the time for new transactions #4027

Answered by MicaiahReid
mookim-eth asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure I understand exactly what you need to do, but maybe this pattern will help:

// ...ganache provider is already instantiated with startup options...

await provider.send("miner_stop"); // stop automatic mining so we can control when blocks are mined

// ...send whatever transactions you need in the block...

const timestamp = Date.now(); // set to whatever timestamp you want the block to have
await provider.send("evm_mine", [{timestamp: timestamp}] ); // mine a block with whatever timestamp you need

Does this help for your use-case?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@davidmurdoch
Comment options

Answer selected by mookim-eth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants