# `EEVM.Gas.Intrinsic`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/gas/intrinsic.ex#L1)

Intrinsic gas costs for transactions — costs that apply before execution begins.

Two main components:

- **Base cost**: 21,000 gas for a regular transaction.
- **Calldata cost**: per-byte fee on the transaction's `data` field —
  4 gas per zero byte, 16 gas per non-zero byte (post-Istanbul / EIP-2028;
  pre-Istanbul, non-zero bytes cost 68 gas).

# `calldata_cost`

```elixir
@spec calldata_cost(binary(), EEVM.HardforkConfig.t()) :: non_neg_integer()
```

Computes the total intrinsic calldata gas cost for the given binary.

Iterates each byte: zero bytes cost `4` gas,
non-zero bytes cost `16` gas from Istanbul (EIP-2028)
and `68` before.

## Examples

    iex> EEVM.Gas.Intrinsic.calldata_cost(<<>>, EEVM.HardforkConfig.new(:cancun))
    0

    iex> EEVM.Gas.Intrinsic.calldata_cost(<<0x00, 0xFF>>, EEVM.HardforkConfig.new(:istanbul))
    20

    iex> EEVM.Gas.Intrinsic.calldata_cost(<<0x00, 0xFF>>, EEVM.HardforkConfig.new(:constantinople))
    72

# `calldata_floor_cost`

```elixir
@spec calldata_floor_cost(binary()) :: non_neg_integer()
```

Computes the Prague calldata floor gas cost for the given calldata.

# `calldata_floor_tokens`

```elixir
@spec calldata_floor_tokens(binary()) :: non_neg_integer()
```

Counts EIP-7623 calldata floor tokens (zero=1, non-zero=4).

# `tx_calldata_floor_token_cost`

```elixir
@spec tx_calldata_floor_token_cost() :: non_neg_integer()
```

Returns the Prague calldata floor gas charged per token.

# `tx_data_non_zero_gas`

```elixir
@spec tx_data_non_zero_gas() :: non_neg_integer()
```

Returns the intrinsic gas cost for non-zero-byte calldata.

Per EIP-2028 (Istanbul): 16 gas per non-zero byte (was 68 pre-Istanbul).

# `tx_data_zero_gas`

```elixir
@spec tx_data_zero_gas() :: non_neg_integer()
```

Returns the intrinsic gas cost for zero-byte calldata.

Per EIP-2028: 4 gas per zero byte.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
