How to know if a transaction went through or not? (out of gas)

  • Apparently when sending transactions from an Account instead of a Wallet, the gas spent is small (21K), and not enough to send ether to a Contract Wallet (out of gas, so to speak).

    When this happens, the transaction shouldn't go through (or be cancelled, as it says here), however it seems to still be recorded in the blockchain, why? Example.

    Doesn't etherscan.io provide any clue about if the transaction ended up being valid or not? In this case it should be marked as CANCELLED/INVALID in that URL, as far as I understand.

    ok thanks, BTW is there a way to know this status via RPC? should I open a new question about this or is there already one?

    It might be similar to this question http://ethereum.stackexchange.com/q/1181/42 ? RPC eth_getTransactionReceipt and checking the gas used is a good way to find out. Sorry I won't flag if you open a new question.

  • eth

    eth Correct answer

    5 years ago

    Using etherscan blockchain explorer

    In etherscan, look for the TxReceipt Status which will have Fail in red, or Success in green.

    Example of a failure: https://ropsten.etherscan.io/tx/0x67a5f6442f49a5da6ff8682250a8eef899d9dc0c5adf20b683709433902b5956

    Using the receipt

    eth.getTransactionReceipt(transactionHash) will return a status field that has a value of 0 when a transaction has failed and 1 when the transaction has succeeded.

    Here's an example showing the status field:

    { blockHash: '0xb1fcff633029ee18ab6482b58ff8b6e95dd7c82a954c852157152a7a6d32785e',
      blockNumber: 4370000,
      contractAddress: null,
      cumulativeGasUsed: 21000,
      gasUsed: 21000,
      logs: [],
      logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
      root: null,
      status: 1, // **** HERE IS THE STATUS FIELD *****
      transactionHash: '0x1421a887a02301ae127bf2cd4c006116053c9dc4a255e69ea403a2d77c346cf5',
      transactionIndex: 0 }
    

    More details here.


    Historical

    To see if a transaction ran out of gas, you can input the transaction (hash) in https://live.ether.camp and then click on "VM Trace". (For the testnet Morden, use https://morden.ether.camp)

    Or plug in the transactionHash in this url:

    https://live.ether.camp/transaction/<transactionHash>/vmtrace#0

    For the transaction mentioned in the question, 022f440fa96eb469363804d7b6c52321d4f409fa76578cdbdc5f04ff494b1321

    here is the output https://live.ether.camp/transaction/022f440fa96eb469363804d7b6c52321d4f409fa76578cdbdc5f04ff494b1321/vmtrace#0

    enter image description here

    This transaction was out of gas immediately. Some transactions may run out of gas after doing some computations, and clicking on the Operations will show each step being performed and when the out of gas happens.

    How is it possible status to be failed, but contract still be deployed? Should not transaction be reverted in case of failure?

    @k06a Think that should be a new question and include your transaction hash so the community can help debug.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM