Ethereum Virtual Machine (EVM) Stack

Introduction

Implementation of the stack operators for the EVM.

Module Contents

Functions

pop

Pops the top item off of stack.

push

Pushes value onto stack.

Module Details

pop

pop(stack: List[ethereum.base_types.U256])ethereum.base_types.U256

Pops the top item off of stack.

Parameters

stack – EVM stack.

Returns

value – The top element on the stack.

Return type

U256

def pop(stack: List[U256]) -> U256:
    if len(stack) == 0:
        raise StackUnderflowError

    return stack.pop()

push

push(stack: List[ethereum.base_types.U256], value: ethereum.base_types.U256)None

Pushes value onto stack.

Parameters
  • stack – EVM stack.

  • value – Item to be pushed onto stack.

def push(stack: List[U256], value: U256) -> None:
    if len(stack) == 1024:
        raise StackOverflowError

    return stack.append(value)