# `EEVM.Database.InMemory`
[🔗](https://github.com/mw2000/eevm/blob/main/lib/eevm/database/in_memory.ex#L1)

In-memory `EEVM.Database` backend backed by plain maps.

The state is a map with two keys:

- `:accounts` — `%{address => account_map}` (balances, nonces, code)
- `:storage` — `%{address => %{slot => value}}` (per-contract storage)

Suitable for testing and single-transaction execution. For persistent
state, implement the `EEVM.Database` behaviour against a disk-backed store.

# `state`

```elixir
@type state() :: %{
  accounts: %{required(non_neg_integer()) =&gt; EEVM.Database.account()},
  storage: %{
    required(non_neg_integer()) =&gt; %{
      required(non_neg_integer()) =&gt; non_neg_integer()
    }
  }
}
```

# `init`

```elixir
@spec init(keyword()) :: state()
```

Creates a new in-memory database state.

## Options

- `:accounts` — initial account map (default: `%{}`)
- `:storage` — initial per-address storage map (default: `%{}`)

## Examples

    iex> state = EEVM.Database.InMemory.init()
    iex> EEVM.Database.InMemory.get_balance(state, 0x1234)
    0

    iex> state = EEVM.Database.InMemory.init(accounts: %{1 => %{balance: 100}})
    iex> EEVM.Database.InMemory.get_balance(state, 1)
    100

# `new`

```elixir
@spec new(keyword()) :: EEVM.Database.t()
```

Convenience: creates a fully wrapped `%Database{}` with InMemory backend.

This is the most common way to create a database for execution.

## Examples

    iex> db = EEVM.Database.InMemory.new()
    iex> EEVM.Database.get_balance(db, 0x1234)
    0

---

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