When I try to execute methods from my smart-contract, I get limited by the gas limit in a block and can't do anything. How to change the gas limit in the block?

  • 3
    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 Commented Feb 17, 2018 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 Commented Feb 17, 2018 at 15:01

4 Answers 4


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, using --targetgaslimit as a flag is a very convenient way to increase or decrease the gas limit of a private chain while developing.

  • 1
    You set gasLimit to 9000000 Million! Its way too much. Please set it to 10000000 (~10 Million), which is the current gas limit for the Ethereum mainnet.
    – alper
    Commented Jan 4, 2020 at 12:04

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.


@Daniel Okwufulueze's answer, sets the gas limit to 9000000 Million.

I do not recommend to set gat limit to exteremly high gas value. Even if you are using a private chain, its better to set gasLimit close to the real mainnet's gasLimit, in order to maintain a realistic simulation environment.

On Ethereum mainnet, current gas limit is ~10 Million (checked on 4 January 2020), please see https://etherscan.io/chart/gaslimit.

Please just add following flag on miner or signer nodes when starting geth:

geth --targetgaslimit '10000000' , follows by other flags.


I just wanted to contribute a solution to similar problems. When you get the error: "err: Error: Returned error: exceeds block gas limit" it might be triggered by the amount of gas you sent for processing the transaction. Normally, you'd think it is fine to send more gas than necessary because any unused gas would be refunded. However, if you provide too much gas to use to process your transaction, it will crash with this error. It seems that the assumption the miner makes is that if you needed to send that much gas, the underlying function is too complicated to process and error prone. They'd have better luck making money mining a simpler transaction.

According to https://www.ethgasstation.info/ The maximum block limit is 8000000, so the amount of gas for your transaction must be less than or equal to this number in hex, i.e. web3.utils.toHex('8000000'), and the same should be true for the gas required of the contract's function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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