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?

  • 1
    But what if developer needs to submit a contract on his just-created private blockchain? Any possibility to change gas limit on genesis block? (geth init genesis.json does not change both difficulty and gasLimit) { "config": { "chainId": 1994, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0 }, "nonce": "0xabcdef0001478042", "timestamp": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "extraData": "0x0", "gasPrice": "0x1", "gasLimit": "0x1fffffffffffff", "difficulty": "400", "mixhash": "0x0000000000000000000000000000000 – user3184743 Feb 17 at 12:17
  • 1
    If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – Roman Frolov Feb 17 at 15:01
up vote 6 down vote accepted

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 localhost:8545:

  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 9000000000000 again.

Basically, --targetgaslimit is a very convenient way to increase or decrease the gas limit of a private chain while developing.

Short answer

Can't or shouldn't.

Better answer

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.

Helpful answer

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.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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