## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

- Auto
- Light
- Dark

# Algorand Specifications

An _Evaluation Context_ ECEC is a core runtime structure used during AVM program execution. It maintains all the state and metadata required to evaluate a program within a transaction (group) scope.

Below is a simplified interface example for the _Evaluation Context_, inspired by the `go-algorand` reference implementation.

These ECEC methods expose context information that remains fixed throughout the execution of a specific transaction within the group:

- `RunMode() -> {SmartSignature, Application}`  
  Returns whether the context is for a _stateless_ LogicSig or a _stateful_ Application.

- `GroupIndex() -> int`  
  Returns the index of the current transaction within its group.

- `PastScratch(past_group_index int) -> map[int, StackValue]`  
  Retrieves the final scratch space of a previous transaction in the same group, by index.

- `GetProgram() -> []byte`  
  Returns the bytecode of the currently executing program ECPECP.

Additional program-related accessors:

- `getCreatorAddress() -> []byte` — Gets the Creator address of the Application.

- `AppID() -> uint64` — Returns the ID of the current Application.

- `ProgramVersion() -> uint64` — AVM version for the executing program.

- `GetOpSpec() -> OpSpec` — Returns the [Opcode Specification](https://specs.algorand.co/avm/avm-appendix-a) for the current opcode.

- `begin(program []byte) -> bool` — Verifies whether the given program version is supported and executable in the current context.

These ECEC reflect the evolving state of execution, may change as the transaction executes.

- `PC() -> int`  
  Returns the current program counter of the executed application ECpcECpc.

The _opcode budget_ limits the AVM program execution.

- `Cost() -> int`  
  Returns the total `opcode` execution cost so far.

- `remainingBudget() -> int`  
  Returns the remaining `opcode` budget available for execution.

- `InnerTxnPending() -> []Transaction`  
  Returns inner transactions that are queued but not yet submitted.

- `addInnerTxn()`  
  Adds an inner transaction to the group. Validates constraints such as group size, fees, and sender address. Used by the `itxn_begin` and `itxn_next` opcodes.

- `step()`  
  The core _transition function_ that advances execution one `opcode` at a time. See the dedicated [non-normative section](https://specs.algorand.co/avm/non-normative/avm-nn-transition-function) for further details.

These functions expose the current Ledger context to the AVM:

- `getRound() -> uint64`  
  Returns the current [round](https://specs.algorand.co/ledger/ledger-round) from the Ledger.

- `getLatestTimestamp() -> uint64`  
  Returns the [latest timestamp](https://specs.algorand.co/ledger/ledger-timestamp) of the most recently committed block.

- `accountRetrieval()`, `assetRetrieval()`, `boxRetrieval()`, `applicationRetrieval()`  
  Provide runtime access to prefetched Ledger data (e.g., foreign accounts, apps, boxes, and assets) as declared in the transaction’s foreign arrays.
