# TxResult.txGasUsed

Returns the gas a receipt reports: `max(totalGasSpent - refunded, floorGas)`.

This is the value a transaction is charged for, which is neither `totalGasSpent` (pre-refund) nor a plain subtraction (the EIP-7623 floor can absorb the refund).

## Imports

:::code-group
```ts [Named]
import { TxResult } from 'ox/evm'
```

```ts [Entrypoint]
import * as TxResult from 'ox/evm/TxResult'
```
:::

## Examples

```ts twoslash
// @noErrors
import { Evm, TxResult } from 'ox/evm'

const result = Evm.callTx(evm, transaction)
TxResult.txGasUsed(result)
// @log: 21000n
```

## Definition

```ts
function txGasUsed(
  result: TxResult,
): bigint
```

**Source:** [src/evm/TxResult.ts](https://github.com/wevm/ox/blob/main/src/evm/TxResult.ts#L129)

## Parameters

### result

* **Type:** `TxResult`

Transaction result.

#### result.createdAddress

* **Type:** `Address.Address | undefined`
* **Optional**

Address of the contract a successful create transaction deployed.

#### result.errorCode

* **Type:** `bigint`
* **Optional**

Host error code raised during execution, if any.

#### result.floorGas

* **Type:** `bigint`

EIP-7623 calldata floor gas. Zero when it does not apply.

#### result.logs

* **Type:** `readonly Log[]`

Logs emitted during execution.

#### result.output

* **Type:** `0x${string}`

Returned data, or revert data when `status` is `false`.

#### result.refunded

* **Type:** `bigint`

Gas refund, capped per EIP-3529, before the EIP-7623 floor applies.

#### result.stateGasSpent

* **Type:** `bigint`

State gas consumed per EIP-8037. Zero when EIP-8037 is disabled.

#### result.status

* **Type:** `boolean`

Whether execution succeeded.

#### result.stop

* **Type:** `"stop" | "return" | "selfDestruct" | "revert" | "callTooDeep" | "outOfFunds" | "createInitCodeStartingEF00" | "invalidEofInitCode" | "invalidExtDelegateCallTarget" | "outOfGas" | ... 22 more ... | "invalidImmediateEncoding"`

Why the interpreter stopped.

#### result.totalGasSpent

* **Type:** `bigint`

Total gas spent, regular plus state, before any refund.

## Return Type

Gas used, after refunds and the calldata floor.

`bigint`
