# `EEVM.WorldState`
[🔗](https://github.com/mw2000/eevm/blob/main/lib/eevm/world_state.ex#L1)

Minimal world/account state used for external account lookups
(`EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`).

Each account can include `:balance`, `:nonce`, `:code`, and `:storage`.
Missing accounts behave like non-existent EVM accounts: no code and
zero balance.

# `account`

```elixir
@type account() :: %{
  optional(:balance) =&gt; non_neg_integer(),
  optional(:nonce) =&gt; non_neg_integer(),
  optional(:code) =&gt; binary(),
  optional(:storage) =&gt; EEVM.Storage.t()
}
```

# `t`

```elixir
@type t() :: %EEVM.WorldState{accounts: %{required(non_neg_integer()) =&gt; account()}}
```

# `account_exists?`

```elixir
@spec account_exists?(t(), non_neg_integer()) :: boolean()
```

# `delete_account`

```elixir
@spec delete_account(t(), non_neg_integer()) :: t()
```

Removes an account entirely from the world state.

Used by SELFDESTRUCT under EIP-6780: when a contract is created and
self-destructed within the same transaction, the account is fully deleted
(balance, nonce, code, and storage are all removed).

# `get_account`

```elixir
@spec get_account(t(), non_neg_integer()) :: account() | nil
```

# `get_balance`

```elixir
@spec get_balance(t(), non_neg_integer()) :: non_neg_integer()
```

# `get_code`

```elixir
@spec get_code(t(), non_neg_integer()) :: binary()
```

# `get_nonce`

```elixir
@spec get_nonce(t(), non_neg_integer()) :: non_neg_integer()
```

# `increment_nonce`

```elixir
@spec increment_nonce(t(), non_neg_integer()) :: t()
```

# `new`

```elixir
@spec new() :: t()
```

# `new`

```elixir
@spec new(%{optional(non_neg_integer()) =&gt; account()}) :: t()
```

# `put_account`

```elixir
@spec put_account(t(), non_neg_integer(), account()) :: t()
```

# `put_code`

```elixir
@spec put_code(t(), non_neg_integer(), binary()) :: t()
```

# `set_balance`

```elixir
@spec set_balance(t(), non_neg_integer(), non_neg_integer()) :: t()
```

# `set_nonce`

```elixir
@spec set_nonce(t(), non_neg_integer(), non_neg_integer()) :: t()
```

# `transfer`

```elixir
@spec transfer(t(), non_neg_integer(), non_neg_integer(), non_neg_integer()) ::
  {:ok, t()} | {:error, :insufficient_balance}
```

# `update_account`

```elixir
@spec update_account(t(), non_neg_integer(), (account() -&gt; account())) :: t()
```

---

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