I use web3 and truffle to get info about my testnet transactions. There are few fields about gas used per transaction, such as: gasPrice, gas, gasUsed. But how to get field 'execution cost'?

  • Does gasPrice * gasUsed sound like what you need? – goodvibration Feb 4 '19 at 12:12
  • No, I need execution gas amount. – Ivan Zakharov Feb 4 '19 at 12:36
  • You need an special EVM like remix that can trace more details, there's no official api that provide such details for geth. – Ismael Feb 6 '19 at 6:16

The field gasUsed is your execution cost. All execution costs are denoted in units of gas in Ethereum.

gasUsed tells you how much gas the transaction actually used. This you can convert directly into Ethers (with the gasPrice) and if you want, you can convert Ethers into real-life currency (fiat) such as euros dollars.

You should read more about gas for example here: What is meant by the term "gas"?

  • Yeah, I know about gas meaning. Your explanation is clear, but not complete. There is a case when tx cost isn't the execution cost. Appears when, as part of a transaction, storage is cleared with the refund of some amount of gas. You should read more about gas for example here: github.com/ethereum/EIPs/issues/1048 – Ivan Zakharov Feb 4 '19 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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