In my transaction: gasPrice: 210000

blockHash: "0x69bd71736f2a5d2c83919a0de81a7de0b6b690bb6bdda3acff254d5c68f634bc",
blockNumber: 3178,
from: "0xc8caa71c16299b40b8579742a27ee53162886040",
gas: 2100000000,
gasPrice: 210000,

And the receipt: gasUsed: 72769

blockHash: "0x69bd71736f2a5d2c83919a0de81a7de0b6b690bb6bdda3acff254d5c68f634bc",
blockNumber: 3178,
contractAddress: null,
cumulativeGasUsed: 72769,
from: "0xc8caa71c16299b40b8579742a27ee53162886040",
gasUsed: 72769,

Is that means my total gas consumed = 72769 x 210000 = 15281490000 or 15GWei?

Can I safely assume gasUsed will remains the same if the execution condition (i.e. input parameters) remain the same? Even when I move my code from test node to the main ETH?

1 Answer 1


Can I safely assume gasUsed will remains the same if the execution condition

No. The gas may vary even calling the sane function. See Why transaction cost for same function differs even though content of function is same? and this.

AlsogasPrice changes dynamically. So you can not always send static gas price (210000). Sending less gas can result into failing of tx and sending less gas price may take a lot of time to get mined.

The better option is to use estimateGas to check for gas of your transactions and eth.gasPrice to estimate gas.

You can increase gas to more what you estimated because extra gas is refuded.

  • I am asking about the gasUsed in the transactionReceipt but not about the gasPrice
    – s k
    Commented Jul 9, 2018 at 9:03
  • gasUsed in tx receipt is the actual gas consumed. This also won't be constant. So may be this time gas consumed is 72769 but on subsequent calls this may vary. Commented Jul 9, 2018 at 9:39
  • I don't think so, since the gasUsed is lower than my gasPrice.
    – s k
    Commented Jul 9, 2018 at 11:12
  • @sk The term gasUsed refers to an entirely different parameter than gasPrice. While gasPrice is the price in wei you will pay to the miner for each unit of gas consumed, gasUsed indicates how many gas units were actually consumed by the transaction. You are probably mistaking gasPrice for gasLimit, which indicates the highest allowable gas consumed on your transaction. Commented Jul 9, 2018 at 12:25
  • @Alex, if you read my original question carefully, I have never confused between gasPrice, gasLimit and gasUsed. It was Prashant
    – s k
    Commented Jul 9, 2018 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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