Options
All
  • Public
  • Public/Protected
  • All
Menu

Interpreter parses and executes a TEAL code. Each transaction is using a new instance of interpreter and doesn't share the interpreter state. When executing the transaction we create a Context (ctx) and pass it to the interpreter. It encapsulates runtime state and the transaction group state (eg shared scratch space). Interpreter must not modify the runtime - the latter will be updated during the context commit phase once all transactions in the groups succeed.

Hierarchy

  • Interpreter

Index

Constructors

Properties

bytecblock: Uint8Array[]
callStack: Stack<number>
cost: number
currentInnerTxnGroup: EncTx[]
gas: number
innerTxnGroups: EncTx[][]
instructionIndex: number
instructions: Op[]
intcblock: BigInt[]
labelMap: Map<string, number>
length: number
lineToCost: {}

Type declaration

  • [key: number]: number
runtime: Runtime
scratch: StackElem[]
stack: TEALStack
tealVersion: number

Methods

  • assertValidTxArray(): void
  • executeWithResult(program: string, runtime: Runtime, debugStack?: number): undefined | StackElem
  • This function executes TEAL code after parsing and returns the result of the program.

    Parameters

    • program: string
    • runtime: Runtime

      : runtime object

    • Optional debugStack: number

    Returns undefined | StackElem

    The final result on the stack or undefined if nothing was on the stack. NOTE: program should fail if there is no result (stack is empty after the execution) or the result is zero.

  • Queries account by accountIndex or ctx.tx.snd (if accountIndex==0). If account address is passed, then queries account by address. When create flag is true we will throws exception if account is not found. When create flag is false we will create new account and add it to context.

    Parameters

    • accountRef: StackElem

      index of account to fetch from account list

    • line: number

      line number

    • create: boolean = false

      create flag, default is true NOTE: index 0 represents txn sender account

    Returns AccountStoreI

  • getAppIDByReference(appRef: number, foreign: boolean, line: number, op: Op): number
  • getAssetDef(assetId: number): undefined | AssetParams
  • getAssetIDByReference(assetRef: number, foreign: boolean, line: number, op: Op): number
  • getBudget(): number
  • getGlobalState(appID: number, key: string | Uint8Array, line: number): undefined | StackElem
  • jumpForward(label: string, line: number): void
  • jumpToLabel(label: string, line: number): void
  • mapLabelWithIndexes(): void
  • printStack(instruction: Op, debugStack?: number): void
  • setGlobalState(appID: number, key: string | Uint8Array, value: StackElem, line: number): void

Generated using TypeDoc