Class Opcode<M>

Represents an opcode found in the bytecode augmented with offset and operand information as defined by the EVM.

It can be either a unary opcode, which does not take any operand data, or either a PUSHn mnemonic augmented with its push data. That is, all but PUSHn n >= 1 opcodes are unary opcodes.

PUSHn n >= 1 opcodes takes an n-byte argument from the bytecode. Note that PUSH0^1 does not take any data argument from the bytecode (just pushes 0 onto the Stack). Thus it can be considered as an unary opcode.

Type Parameters

  • M extends string = string

Hierarchy

  • Opcode

Constructors

Properties

Accessors

Methods

Constructors

  • Type Parameters

    • M extends string = string

    Parameters

    • pc: number

      The Program Counter of this Opcode. The index in the Opcode[] where this Opcode is inserted.

    • opcode: number

      Any byte number, i.e., between 0 and 255 representing the opcode byte. The opcode may not be a valid opcode.

    • mnemonic: M

      Represents a valid opcode.

      In https://www.evm.codes/ you can find an overview of each EVM opcode.

      If the opcode given is not a valid opcode, you can provide INVALID as mnemonic.

      A PUSHn opcode only permits a PUSHn opcode.

    • data: null | Uint8Array = null

      A Unary opcode does not include any data. For these opcodes data is null.

      If this Opcode is a PUSHn instruction or contains any operand data, then it contains the data attached to this instruction.

    Returns Opcode<M>

Properties

data: null | Uint8Array = null

A Unary opcode does not include any data. For these opcodes data is null.

If this Opcode is a PUSHn instruction or contains any operand data, then it contains the data attached to this instruction.

mnemonic: M

Represents a valid opcode.

In https://www.evm.codes/ you can find an overview of each EVM opcode.

If the opcode given is not a valid opcode, you can provide INVALID as mnemonic.

A PUSHn opcode only permits a PUSHn opcode.

opcode: number

Any byte number, i.e., between 0 and 255 representing the opcode byte. The opcode may not be a valid opcode.

pc: number

The Program Counter of this Opcode. The index in the Opcode[] where this Opcode is inserted.

Accessors

  • get nextpc(): number
  • Where the next opcode should be located at.

    Returns number

Methods

  • Returns a string representation of this Opcode. Usually used for debugging purposes.

    Parameters

    • includeDataAsNumeric: boolean = true

      whether to include data as numeric.

    Returns string

    the string representation of this Opcode.

  • Returns the hexadecimal representation of this.data.

    Returns undefined | string

Generated using TypeDoc v0.25.2