# `EEVM.Handler.Validation`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/handler/validation.ex#L1)

Pre-flight checks on a wire transaction.

This phase handles steps 1-3 of the transaction pipeline (Yellow Paper §6):

1. **Decode** the wire bytes (or accept an already-decoded typed struct).
2. **Recover sender** via secp256k1 ecrecover on the typed signing hash.
3. **Validate** intrinsic gas, nonce, balance, EOA sender, EIP-1559 fee
   constraints, blob/initcode size rules.

Outputs `{:ok, %EEVM.TxEnv{}}` ready for the next phase, or
`{:error, reason}` for any failure.

# `decoded_tx`

```elixir
@type decoded_tx() ::
  EEVM.Transaction.Legacy.t()
  | EEVM.Transaction.AccessList.t()
  | EEVM.Transaction.FeeMarket.t()
  | EEVM.Transaction.Blob.t()
  | EEVM.Transaction.SetCode.t()
```

# `wire_tx`

```elixir
@type wire_tx() :: decoded_tx() | binary()
```

# `build_tx_context`

```elixir
@spec build_tx_context(decoded_tx(), non_neg_integer()) :: {:ok, EEVM.TxEnv.t()}
```

Build the `EEVM.TxEnv` the EVM sees from a decoded transaction.

# `ensure_decoded`

```elixir
@spec ensure_decoded(wire_tx()) :: {:ok, decoded_tx()} | {:error, atom()}
```

Decode wire bytes into a typed transaction struct, or pass a struct through.

# `recover_sender`

```elixir
@spec recover_sender(decoded_tx(), non_neg_integer()) ::
  {:ok, non_neg_integer()} | {:error, atom()}
```

Recover the sender address; see `EEVM.Transaction.Signer.recover_sender/2`.

# `resolve_config`

```elixir
@spec resolve_config(keyword()) :: EEVM.Config.t()
```

Use `opts[:config]` if given, else build one from `opts[:hardfork]` (default
`:cancun`). The deprecated `:chain_id` option, when given, overrides the
config's chain id.

# `resolve_tracer`

```elixir
@spec resolve_tracer(keyword()) :: EEVM.Tracer.t() | nil
```

The `EEVM.Tracer` that `opts[:tracer]` asks for: a new one for `true`, the
given one, or `nil` (no tracing) when absent or `false`.

# `validate`

```elixir
@spec validate(
  EEVM.TxEnv.t(),
  EEVM.Database.t(),
  EEVM.BlockEnv.t(),
  EEVM.HardforkConfig.t()
) ::
  :ok | {:error, atom()}
```

Validate the transaction against state; see `EEVM.Transaction.Validator.validate/4`.

---

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