# `EEVM.StateChanges`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/state_changes.ex#L1)

The state a transaction, block, or call wrote, as a backend's
`c:EEVM.Database.commit/2` receives it and results carry it in `changes`.

`accounts` maps each written address to either `:destroyed`, when the
account no longer exists, or its new state:

| Key | Description |
|-----|-------------|
| `balance`, `nonce` | The account's new balance and nonce |
| `code_hash` | keccak256 of its code |
| `code` | The code when the backend may not have it yet, else `nil` |
| `storage` | The written slots, `%{slot => value}`; a value of 0 clears the slot |
| `destroyed?` | The account and all its storage were deleted first, so apply `storage` to an empty store |

Apply each address independently: for `:destroyed`, delete the account and
its storage; otherwise clear its storage if `destroyed?`, write the account
fields, store `code` under `code_hash` when it is set, and apply `storage`.

# `account_change`

```elixir
@type account_change() :: %{
  balance: non_neg_integer(),
  nonce: non_neg_integer(),
  code_hash: &lt;&lt;_::256&gt;&gt;,
  code: binary() | nil,
  storage: %{required(non_neg_integer()) =&gt; non_neg_integer()},
  destroyed?: boolean()
}
```

# `t`

```elixir
@type t() :: %EEVM.StateChanges{
  accounts: %{required(non_neg_integer()) =&gt; account_change() | :destroyed}
}
```

---

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