When I try to execute methods from my smart-contract, I get limeted by gas limit in block and cant do anything. How to change gas limit in block?
While it's advised to not alter a chain's gas limit once created, it may become necessary to fiddle with the gas limit of an existing private blockchain, especially during development.
On geth, this can be done by setting the
--targetgaslimit flag when starting the node. For example, you may do the following for a network with id
666 running on
geth --networkid '666' --datadir 'path/to/your/chain/db' --targetgaslimit '9000000000000' --rpc --rpccorsdomain 'localhost:8545' --mine
The above will start your node and keep pushing the gas limit towards
9000000000000 as mining continues. Over time, the gas limit would have grown so large that you'll not have the
Error: exceeds block gas limit issue anymore.
Of course, closing the node and restarting repeats the process from the initial gas limit of the chain all the way towards
--targetgaslimit is a very convenient way to increase or decrease the gas limit of a private chain while developing.
Can't or shouldn't.
The block gaslimit is a property of the network. If you're using a private chain you can fiddle with it in the genesis block. On a real blockchain, this property is periodically voted on by the miners. See Yellow Paper.
More info here: What does each genesis.json parameter mean?
gasLimit A scalar value equal to the current chain-wide limit of Gas expenditure per block. High in our case to avoid being limited by this threshold during tests. Note: this does not indicate that we should not pay attention to the Gas consumption of our Contracts.
Consider restructuring the contract with a mind to reducing the gas requirement. The live Ethereum network has a moveable limit. https://ethstats.net/
Hope it helps.