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 referencedethAPIs are part of the Web3.js library.

  • 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 ofeth.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 asgasin output ofeth.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 ofeth.getTransaction("<transaction_hash>")

Common Symptoms, Causes and Solutions

  • “Gas provided” for transaction is not high enough to cover the gas needed to execute the transaction.
    • Likely error message:intrinsic gas too low.
    • Fix: Supply a highergasamount, or use a client like the Kaleido REST API Gateway that automatically estimates gas for your transactions (importantly also adding a 20% contingency on top before submission)
  • Thefrom accountdoes not have enough Ether to execute transaction.
    • Likely error message:insufficient funds for gas * price + value
    • Note: This will only occur if thegasPricefor the transaction is set to some value other than the default 0.
    • Fix: Use a debugger like Remix to debug your infinite loop
  • Infinite loop or other unbounded processing error in smart contract code
    • Likely error messageTX ran out of gas before completion
    • Fix: Use a debugger like Remix to debug your infinite loop
  • Contract is not compiled for the correct EVM version
    • Likely error messagegas required exceeds allowance or always failing transaction
    • Fix: Compile with--evm-version byzantium
    • Note: If you need more recent opcodes, please contact us to confirm the hard fork that is supported in Kaleido and meets your needs.
  • Contract has reverted
    • Likely error messagegas required exceeds allowance or always failing transaction
    • Fix: Runeth_callwith exactly the same parameters, then process the output per the Solidity control structures doc to get the error message of the revert
    • Note: Some web3 interfaces, including Truffle, and the Kaleido REST API Gateway, perform aneth_callautomatically for you when this occurs during gas estimation and return the error string, rather than the generic message
Was this article helpful?
0 out of 0 found this helpful