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

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: {
    [key: number]: number;
}

Type declaration

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

Methods

  • This function executes TEAL code after parsing and returns the result of the program.

    Returns

    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.

    Parameters

    • program: string
    • runtime: Runtime

      : runtime object

    • Optional debugStack: number

    Returns undefined | StackElem

  • 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

    • createFlag: boolean = false

      create flag, default is true

    • immutable: boolean = true

      allow to access foreign application account or not(false), default is true NOTE: index 0 represents txn sender account

    Returns AccountStoreI

  • Queries appIndex by app reference (offset to foreignApps array OR index directly)

    • Since TEALv4, any reference is supported (but it must be present in foreignApps array)
    • For older versions, if foreign === true, reference is treated as offset to foreignApps array, otherwise it is treated as a direct reference.

    Parameters

    Returns number

  • Queries ASA Definitions data by assetID. Returns undefined if ASA is not deployed.

    Parameters

    • assetId: number

      Asset Index

    Returns undefined | AssetParams

  • Queries assetIndex by asset reference (offset to foreignAssets array OR index directly)

    • Since TEALv4, any reference is supported (but it must be present in foreign assets array)
    • For older versions, if foreign === true, reference is treated as offset to foreignAssets array, otherwise it is treated as a direct reference.

    Parameters

    Returns number

  • logs TEALStack upto depth = debugStack to console

    Parameters

    • instruction: Op

      interpreter opcode instance

    • Optional debugStack: number

      max no. of elements to print from top of stack

    Returns void

Generated using TypeDoc