How can I get gas used in a transaction?

Viewing transaction using the CLI doesn’t have any value for gas_used. Following is an example of such transaction that execute a procedure on a custom module:

Committed transaction: TransactionView {
    version: 21038603,
    transaction: UserTransaction {
        sender: "2420df573b3f64142f248982d395642a",
        signature_scheme: "Scheme::Ed25519",
        signature: "a2425f4902ed29ec958d86705a1a71aa61f2a55852e9d68b5bc85c3fcf3b26b87e84a6f4de28066595d43fb9ec19691d200949874dca8972dbcd63bce32cf90d",
        public_key: "1b1d2d5b7b11ab35160f1e28b333d08e834a191f17cd03844b733ab5e3410a40",
        sequence_number: 100,
        max_gas_amount: 1000000,
        gas_unit_price: 0,
        expiration_time: 1590231050,
        script_hash: "fe7b3b7c005e185e5411f9e7e6799b53a200b1afd8717554615feb6a35fdd911",
        script: Unknown,
    },
    events: [],
    vm_status: EXECUTED,
    gas_used: 0,
}

How can I get gas used in a transaction ?

as it is shown, the gas_used number is 0 :

and this is because you set gas_unit_price to 0 in this transcation.

1 Like

base on the discussion, this field actually will change into gas unit now, so it is not the fee of the transactions anymore after next reelease.