HomeFAQsWhy am I getting "transaction out of gas" errors?

Why am I getting "transaction out of gas" errors?

A common error message that Kaleido users have encountered when trying to execute smart contract transactions is “out-of-gas.” This document describes some of the known causes and potential fixes.

Here are some definitions of terms related to gas. The referenced eth APIs are part of the Web3.jslibrary.

  • gas: unit of measurement for the computational work of running transactions or smart contracts in the Ethereum network
  • gasLimit: maximum amount of gas that can be spent on all transactions within a single block. This is not configurable by Kaleido users.
    • Listed as gasLimit in output of eth.getBlock("<block_hash>")
    • The miner of a new block can set the gas limit within +/- 0.1 % of the parent block’s gas limit
  • gas provided: maximum amount of gas you’re willing to spend on a particular transaction
    • Listed as gas in output of eth.getTransaction("<transaction_hash>")
  • gasPrice: the amount of Ether you’re willing to pay for every unit of gas, measured in Gwei (1 ETH = 1M Gwei)
    • Listed as gasPrice in output of eth.getTransaction("<transaction_hash>")


  1. “Gas provided” for transaction is not high enough to cover the gas needed to execute the transaction. Error message: intrinsic gas too low. See Fix #1
  2. The from account does not have enough Ether to execute transaction. This will only occur if the gasPrice for the transaction is set to some value other than the default 0. Error message: insufficient funds for gas * price + value. See Fix #2
  3. Infinite loop or other unbounded processing error in smart contract code. Error message (if using kaleido-go >v0.1.2 for Geth node):TX failed. Status=0. TX ran out of gas before completion. See Fix #3
  4. Kaleido genesis block is not configured for latest EVM settings. The hard fork implemented by EIP150 was not used by Kaleido release versions <0.1.12. This may cause an “out-of-gas” error when a contract that calls methods from other contracts is compiled with Solidity versions >0.4.18. See Fix #4 (recommended). Alternatively, can use Fix #5 or Fix #6 as work-arounds.
  5. In Geth if a require call fails in a called smart contract, the error is reported as “out-of-gas” (rather than “execution reverted”, or a detailed reason for the require failing).

Potential fixes

  1. Using kaleido-go: run your transaction with the -E (estimate gas) flag to get an idea of how much the transaction should cost. Then, verify that you are providing at least that much gas when sending the actual transaction. The default gas provided with kaleido-go is 1,000,000, but is configurable using the -g flag. Execute the following commands from a terminal window after following the kaleido-go installation guide. This will output the estimated gas for that transaction.
    • NODE_URL="https://<user>:<password>@<node_rpc_endpoint>"
    • ACCOUNT=<ethereum_account>
    • ./kaleido-go -f examples/simplestorage.sol -c <contract_hash> -E -m set -x 1026 -u "$NODE_URL" -a "$ACCOUNT

  2. Provide the from account parameter with more Ether so that it can afford to fund the transaction. This can be accomplished by using the Ether Pool service inside the Kaleido environment console. Ensure that the gas versus gasPrice ratio is large enough.
  3. Fix smart contract source code to remove unbounded processing.
  4. Create a new Kaleido environment with the latest release. Due to the immutable nature of blockchains, the genesis block cannot be reconfigured for a pre-existing environment so the user will have to create a brand new environment to get the latest genesis block configuration.
  5. Revert back to solc (Solidity compiler) v0.4.18. Solc v0.4.21-24 have produced errors for the same cross-contract method calls that work error-free in v0.4.18 if the Kaleido environment was created using Kaleido release version <v0.1.12. Make sure that the .sol files specify the correct compiler version:
    • Will work with any solc v0.4.x: pragma solidity ^0.4.0;
    • Will work with only solc v0.4.18: pragma solidity ^0.4.18;
  6. Edit Solidity code to add gas value to actual contract method call AND “.gas(xxxxx)” to all cross-contract calls.
  • Original: myMethod(address, price, {from: data.accounts[0]}))
  • Fix: myMethod(address, price, {from: data.accounts[0], gas: 1000000}))
  • Original: ERC20(token).transferFrom(user, toAddress, amount);
  • Fix: ERC20(token).transferFrom.gas(450000)(user, toAddress, amount);