EVM memory — a byte-addressable, dynamically expanding linear memory.
Memory expands in 32-byte chunks. Reads or writes beyond the current size
auto-expand and are zero-filled. Gas cost increases quadratically with
memory size (see EEVM.Gas.Memory).
Summary
Functions
Copies length bytes from src to dst within memory (memmove semantics).
Loads a 256-bit (32-byte) word from the given byte offset.
Creates a new empty memory.
Reads a range of bytes from memory as a binary.
Returns the current memory size in bytes (always a multiple of 32).
Stores a 256-bit (32-byte) word at the given byte offset.
Stores a single byte at the given offset.
Types
@type t() :: %EEVM.Interpreter.Memory{ data: %{required(non_neg_integer()) => byte()}, size: non_neg_integer() }
Functions
@spec copy(t(), non_neg_integer(), non_neg_integer(), non_neg_integer()) :: t()
Copies length bytes from src to dst within memory (memmove semantics).
This is the MCOPY operation (EIP-5656). Handles overlapping regions correctly
by reading all source bytes before writing — similar to C's memmove.
@spec load(t(), non_neg_integer()) :: {non_neg_integer(), t()}
Loads a 256-bit (32-byte) word from the given byte offset.
This is the MLOAD operation. Unwritten bytes read as zero.
@spec new() :: t()
Creates a new empty memory.
@spec read_bytes(t(), non_neg_integer(), non_neg_integer()) :: {binary(), t()}
Reads a range of bytes from memory as a binary.
Used by RETURN, REVERT, and LOG operations.
@spec size(t()) :: non_neg_integer()
Returns the current memory size in bytes (always a multiple of 32).
@spec store(t(), non_neg_integer(), non_neg_integer()) :: t()
Stores a 256-bit (32-byte) word at the given byte offset.
This is the MSTORE operation. The value is stored big-endian, which is the EVM's byte ordering convention.
@spec store_byte(t(), non_neg_integer(), non_neg_integer()) :: t()
Stores a single byte at the given offset.
This is the MSTORE8 operation.