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

Steps 9-11 of the transaction pipeline:

- **Settle gas refund** — the sender was debited `gas_limit * max_price`
  upfront. They actually owe `gas_used * effective_price`. Refund the
  difference. On a successful tx the refund lands in the EVM-side db (which
  already reflects every side effect); on revert / out-of-gas / invalid it
  lands in the post-upfront, post-nonce-bump db, which also holds any
  EIP-7702 delegations (since EVM mutations are dropped).

- **Coinbase reward** — credit the block proposer
  `(effective_price - basefee) * gas_used`.

- **Build receipt + result** — produce the `EEVM.TransactionResult`
  struct that callers consume.

# `finalize`

```elixir
@spec finalize(
  EEVM.Interpreter.MachineState.t(),
  non_neg_integer() | nil,
  EEVM.Context.Transaction.t(),
  binary(),
  EEVM.Database.t(),
  EEVM.Context.Block.t()
) :: {:ok, EEVM.TransactionResult.t()}
```

Settle gas, credit the coinbase, and build the `EEVM.TransactionResult`.

The database argument is the state after upfront charging, the nonce
bump, and EIP-7702 authorizations; settlement starts from it when
execution failed.

---

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