Ethereum Virtual Machine (EVM) Memory
Table of Contents
Introduction
EVM memory operations.
Module Contents
Functions
Writes to memory. |
|
Read bytes from memory. |
|
Read bytes from a buffer. Padding with zeros if neccesary. |
Module Details
memory_write
- memory_write(memory: bytearray, start_position: ethereum.base_types.U256, value: ethereum.base_types.Bytes) → None
Writes to memory.
- Parameters
memory – Memory contents of the EVM.
start_position – Starting pointer to the memory.
value – Data to write to memory.
def memory_write(
memory: bytearray, start_position: U256, value: Bytes
) -> None:
memory[start_position : Uint(start_position) + len(value)] = value
memory_read_bytes
- memory_read_bytes(memory: bytearray, start_position: ethereum.base_types.U256, size: ethereum.base_types.U256) → bytearray
Read bytes from memory.
- Parameters
memory – Memory contents of the EVM.
start_position – Starting pointer to the memory.
size – Size of the data that needs to be read from start_position.
- Returns
Data read from memory.
- Return type
data_bytes
def memory_read_bytes(
memory: bytearray, start_position: U256, size: U256
) -> bytearray:
return memory[start_position : Uint(start_position) + Uint(size)]
buffer_read
- buffer_read(buffer: ethereum.base_types.Bytes, start_position: ethereum.base_types.U256, size: ethereum.base_types.U256) → ethereum.base_types.Bytes
Read bytes from a buffer. Padding with zeros if neccesary.
- Parameters
buffer – Memory contents of the EVM.
start_position – Starting pointer to the memory.
size – Size of the data that needs to be read from start_position.
- Returns
Data read from memory.
- Return type
data_bytes
def buffer_read(buffer: Bytes, start_position: U256, size: U256) -> Bytes:
return right_pad_zero_bytes(
buffer[start_position : Uint(start_position) + Uint(size)], size
)