5

I am using the Ganache CLI for testing my smart contracts and frontends. I need a way to incorporate a delay into ganache-cli when performing write transactions in order for it to more closely resemble the mainnet

I read that I should use the -b or --blockTime flag, however whenever launching ganache-cli with -b 15 my write transactions are still mined instantly.

Can anyone suggest the proper approach here?

Thanks!

2

Your approach is the good one as far as i know. I've been using this option and it always worked.

However note that having a 15 seconds block doesn't mean that when you send your transaction it will be mined in 15 seconds, sometimes it will be less.

e.g : as last block was mined 9 seconds ago, next block should be mined in 6 seconds and chain receives a transaction, your transaction will be then executed in 6 seconds, even if option has been set to 15 seconds.

Have you tried chaining multiple transactions ?

If you still state that your transactions are computed instantly maybe you should open an issue on the ganache-cli repo, giving the information related to your environment, versions, etc.

  • I haven't tried changing multiple transactions. Just doing multiple writes with Web3 in one go? – Dan Apr 6 '18 at 4:34
  • 1
    Looks like -b is indeed the proper flag and there is an issue with the current build I was using. It works properly using the Ganache UI – Dan Apr 12 '18 at 2:59
  • I have not gotten this working with Ganache-cli, are you saying that I can start the UI with the same parameters as cli and get the desired result? These parameters don't appear to be options in the settings menu when I run the UI. – Phillip Gibb May 3 '18 at 13:41
  • i don't know as i never used anything else other than the CLI in my own case – Asone May 3 '18 at 17:37
0

I think this is a problem with ganache-cli. I just created an issue in their repo.

For now, switch to Ganache UI.

The accepted answer is misleading. As the OP acknowledges in the comment, he also ended up using Ganache UI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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