Class Memory<E>

EVM memory is not persistent and is destroyed at the end of the call context. At the start of a call context, memory is initialized to 0. Reading and Writing from memory is usually done with MLOAD and MSTORE instructions respectively, but can also be accessed by other instructions like CREATE or EXTCODECOPY.[1]

[1] https://www.evm.codes/about#memory

Type Parameters

  • in out E

Hierarchy

  • Memory

Constructors

  • Creates a new Memory with no locations set.

    Type Parameters

    • in out E

    Parameters

    • _map: Map<bigint, E> = ...

    Returns Memory<E>

Properties

_map: Map<bigint, E> = ...
maxInvalidateSizeAllowed: bigint = ...

Defines the maximun size allowed to invalidate.

Accessors

  • get size(): number
  • Returns number

    the number of values stored in the Memory.

Methods

  • Creates a shallow copy of this Memory. That is, the keys are copied but the values are kept the same for both this Memory and the cloned one.

    Returns Memory<E>

    a new Memory with the same elements as this one.

  • Returns a specified value from the Memory object. If the value stored at the provided location is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Memory.

    Parameters

    • location: bigint

    Returns undefined | E

    Returns the value stored at the specified location. If no value is stored at the specified location, undefined is returned.

  • Parameters

    • location: bigint

    Returns boolean

    boolean indicating whether a value in the specified location exists or not.

  • Invalidates the whole memory region.

    That is, after invalidateAll, get with any argument will return undefined.

    Returns void

  • Tries to invalidate the memory range indicated by [offset, offset + size]. It can do so when both offset and size are reducible to Val, and size is no greater than maxInvalidateSizeAllowed. This last restriction is to avoid iterating over a large range.

    Otherwise, when invalidateAll is set clears the whole memory.

    Parameters

    • offset: Expr

      the offset in memory to invalidate.

    • size: Expr

      the size to invalidate.

    • invalidateAll: boolean = true

      indicates to clear the whole memory in case neither offset nor size are not reducible to Val.

    Returns void

  • Parameters

    • offset: bigint
    • size: bigint
    • miss: ((location) => E)
        • (location): E
        • Parameters

          • location: bigint

          Returns E

    Returns E[]

  • Sets the new value at the specified location. If a value at the same location already exists, the value will be updated.

    Parameters

    • location: bigint
    • value: E

    Returns Memory<E>

    the this Memory so calls can be chained.

Generated using TypeDoc v0.25.2