# `EEVM.Handler.Execution`
[🔗](https://github.com/mw2000/eevm/blob/main/lib/eevm/handler/execution.ex#L1)

Step 8 of the transaction pipeline — actually run the EVM.

Two paths:

- **Call** (`tx.to` is a 20-byte address): transfer `tx.value`, fetch the
  code at `to`, and run the interpreter against it. When `to` is an active
  precompile with no code, the precompile runs on `tx.data` instead.
- **Create** (`tx.to` is `nil`): derive the new contract address, fail
  with all execution gas consumed if it collides with an existing account
  (EIP-684, EIP-7610), transfer `tx.value`, run `tx.data` as initcode,
  then deploy whatever the initcode
  returns as the new account's runtime code (subject to size and EIP-3541
  deposit-cost checks).

Returns `{final_state, contract_address}` where `contract_address` is the
newly-deployed address (CREATE path) or `nil` (call path).

From Prague, a call to an account whose code is an EIP-7702 delegation
designator runs the delegate's code instead, with the delegate pre-warmed.

# `run_top_level`

```elixir
@spec run_top_level(
  EEVM.Context.Transaction.t(),
  EEVM.Database.t(),
  EEVM.Context.Block.t(),
  EEVM.Config.t(),
  non_neg_integer(),
  EEVM.Handler.PreExecution.authorization_outcome()
) :: {EEVM.Interpreter.MachineState.t(), non_neg_integer() | nil}
```

Runs a validated transaction's EVM execution with `execution_gas` against
`db`, in which the sender's nonce is already bumped and any EIP-7702
authorizations are applied.

`authorization` is the outcome of `PreExecution.apply_authorizations/3`:
its authorities start warm and its refund is added to the transaction's
refund counter even if execution fails.

Returns the final machine state and the deployed contract address, or `nil`
for a message call or a failed deployment.

---

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