[Ethereum] Gas and “Gas Used By Transaction” and how to get both values through json-rpc

blockchainfeesgasjson-rpctransactions

On testnet I am analyzing the following transaction https://testnet.etherscan.io/tx/0x7b111a37998b25116b1a6962d393253bf09613dd083b420ec24ffc9a28bc74b6
having this attributes:

Gas: 90000 and Gas Used By Transaction: 21000

I guess 21000 is the actual fee applied to this tx, but what is Gas: 90000 then?

I am a bit confused because when querying this tx through json-rpc on my geth node using eth_getTransactionByHash method I got this result:

gas => 0x15f90 = 90000

but there is no field gasUsed or similar. So it seems there is no way to find out actual tx fee, right?

How can I get gasUsed value for a tx using json-rpc calls?

Best Answer

The gas value is sent by the external account that created the transaction. With the transaction object { from: account: gas: 90000, ... }. When you call eth.getTransaction("0x..") you get the same value.

The gasUsed can be retrieved with eth.getTransactionReceipt("0x..").

Related Topic