Cumulative Gas Used - what is it?

What is the 'Cumulative Gas Used' by a contract?

Comments

  • GeorgeHallamGeorgeHallam Member, Administrator, Moderator Posts: 229 admin
    Cumulative Gas Used is the total gas used in a contract over time.

    Let's look at this transaction for example: http://etherscan.io/tx/0xa88384086663bd15c04667086e370ba00cde7ed9a33a6554955ff3b7c3683580

    Value: 227,999 Ether
    Gas: 150000
    Gas Price: 57.514345997 Gwei (0.000000057514 Ether)
    Gas Used By Transaction: 99110
    Actual Transaction Cost: 5.70024683 Finney (0.005700246832 Ether)
    Cumulative Gas Used: 99110

    So here, we can see the sender specified 150000 gas to be used in the TX. However, only 99110 gas was actually required for the transaction to go through, so the remaining 50890 gas was returned to the sender. If this transaction was being used with a smart contact, cumulative gas used would show the total amount of gas that has been used to interact with it, which may involve multiple TXs.
  • celticwarrior72celticwarrior72 Member Posts: 83
    Thanks George. I've been trying to get a better understanding of actual transactions costs in different cases.
  • celticwarrior72celticwarrior72 Member Posts: 83

    If this transaction was being used with a smart contact, cumulative gas used would show the total amount of gas that has been used to interact with it, which may involve multiple TXs.

    Just a quick clarification - does that mean that 'Cumulative Gas Used' keeps track of the total amount of gas that a contract consumes over time? In which case, I'd expect to see a contract that has had many transactions (http://etherscan.io/address/0x020522bf9b8ed6ff41e2fa6765a17e20e2767d64) show a high value for 'Cumulative Gas Used' for more recent transactions, which it does not seem to do.
  • mtbitcoinmtbitcoin Member Posts: 40
    I would be interested in understanding this also. Can contracts be funded in wei by the following transactions (creating new send tx to the contract address) or is the maximum amount of gas that a contract can consume fixed at the time of the contract creation ?
Sign In or Register to comment.