Web3.js – How to Insert Multiple Transactions into One Block in Ganache GUI

contract-invocationganachejavascriptnodejsweb3js

Is it possible to enable Ganache GUI to put multiple transactions into ONE block ?. The details about Why i need this thing, is given below;

I am going to test Transaction Order Dependence (TOD) contracts details are here, which need multiple transactions into one block (if i am not wrong). To achieve the real behavior of true miner, i have to test A race condition vulnerability in my contract. So, is it possible to launch TOD attack using Ganache ?

Best Answer

Ganache can be configured to mine new blocks on a specific time interval. With this setting enabled you are able to include multiple transactions in a single block.

To enable this functionality in the GUI, access the settings by clicking the gear icon in the top right corner. Choose "Server" settings. From there you will be able to disable auto-mining and set the number of seconds between blocks.

To enable it in ganache-cli, include the --blockTime [number] flag when launching the program. [number] is the number of seconds between blocks.