applications.app_manager | Algorand Developer Portal

applications.app_manager

Attributes

UPDATABLE_TEMPLATE_NAME The name of the TEAL template variable for deploy-time immutability control.
DELETABLE_TEMPLATE_NAME The name of the TEAL template variable for deploy-time permanence control.

Classes

AppManager A manager class for interacting with Algorand applications.

Module Contents

algokit_utils.applications.app_manager.UPDATABLE_TEMPLATE_NAME = ‘TMPLUPDATABLE’_

The name of the TEAL template variable for deploy-time immutability control.

algokit_utils.applications.app_manager.DELETABLE_TEMPLATE_NAME = ‘TMPLDELETABLE’_

The name of the TEAL template variable for deploy-time permanence control.

class algokit_utils.applications.app_manager.AppManager(algod_client: algosdk.v2client.algod.AlgodClient)

A manager class for interacting with Algorand applications.

Provides functionality for compiling TEAL code, managing application state, and interacting with application boxes.

app_manager = AppManager(algod_client)

compile_teal(teal_code: str) → algokit_utils.models.application.CompiledTeal

Compile TEAL source code.

compile_teal_template(teal_template_code: str, template_params: algokit_utils.models.state.TealTemplateParams | None = None, deployment_metadata: collections.abc.Mapping[str, bool | None] | None = None) → algokit_utils.models.application.CompiledTeal

Compile a TEAL template with parameters.

app_manager = AppManager(algod_client)

teal_template_code =

# This is a TEAL template

# It can contain template variables like {TMPL_UPDATABLE} and {TMPL_DELETABLE}

compiled_teal = app_manager.compile_teal_template(teal_template_code)

get_compilation_result(teal_code: str) → algokit_utils.models.application.CompiledTeal | None

Get cached compilation result for TEAL code if available.

app_manager = AppManager(algod_client)

teal_code = "RETURN 1"

compiled_teal = app_manager.compile_teal(teal_code)

compilation_result = app_manager.get_compilation_result(teal_code)

get_by_id(app_id: int) → algokit_utils.models.application.AppInformation

Get information about an application by ID.

app_manager = AppManager(algod_client)

app_id = 1234567890

app_info = app_manager.get_by_id(app_id)

get_global_state(app_id: int) → dict[str, algokit_utils.models.application.AppState]

Get the global state of an application.

app_manager = AppManager(algod_client)

app_id = 123

global_state = app_manager.get_global_state(app_id)

get_local_state(app_id: int, address: str) → dict[str, algokit_utils.models.application.AppState]

Get the local state for an account in an application.

app_manager = AppManager(algod_client)

app_id = 123

address = "SENDER_ADDRESS"

local_state = app_manager.get_local_state(app_id, address)

get_box_names(app_id: int) → list[ algokit_utils.models.state.BoxName]

Get names of all boxes for an application.

If the box name can’t be decoded from UTF-8, the string representation of the bytes is returned.

app_manager = AppManager(algod_client)

app_id = 123

box_names = app_manager.get_box_names(app_id)

get_box_value(app_id: int, box_name: algokit_utils.models.state.BoxIdentifier) → bytes

Get the value stored in a box.

app_manager = AppManager(algod_client)

app_id = 123

box_name = "BOX_NAME"

box_value = app_manager.get_box_value(app_id, box_name)

get_box_values(app_id: int, box_names: list[algokit_utils.models.state.BoxIdentifier]) → list[bytes]

Get values for multiple boxes.

app_manager = AppManager(algod_client)

app_id = 123

box_names = ["BOX_NAME_1", "BOX_NAME_2"]

box_values = app_manager.get_box_values(app_id, box_names)

get_box_value_from_abi_type(app_id: int, box_name: algokit_utils.models.state.BoxIdentifier, abi_type: algokit_utils.applications.abi.ABIType) → algokit_utils.applications.abi.ABIValue

Get and decode a box value using an ABI type.

app_manager = AppManager(algod_client)

app_id = 123

box_name = "BOX_NAME"

abi_type = ABIType.UINT

box_value = app_manager.get_box_value_from_abi_type(app_id, box_name, abi_type)

get_box_values_from_abi_type(app_id: int, box_names: list[algokit_utils.models.state.BoxIdentifier], abi_type: algokit_utils.applications.abi.ABIType) → list[algokit_utils.applications.abi.ABIValue]

Get and decode multiple box values using an ABI type.

app_manager = AppManager(algod_client)

app_id = 123

box_names = ["BOX_NAME_1", "BOX_NAME_2"]

abi_type = ABIType.UINT

box_values = app_manager.get_box_values_from_abi_type(app_id, box_names, abi_type)

static get_box_reference(box_id: algokit_utils.models.state.BoxIdentifier | algokit_utils.models.state.BoxReference) → tuple[int, bytes]

Get standardized box reference from various identifier types.

app_manager = AppManager(algod_client)

app_id = 123

box_name = "BOX_NAME"

box_reference = app_manager.get_box_reference(box_name)

static get_abi_return(confirmation: algosdk.v2client.algod.AlgodResponseType, method: algosdk.abi.Method | None = None) → algokit_utils.applications.abi.ABIReturn | None

Get the ABI return value from a transaction confirmation.

app_manager = AppManager(algod_client)

app_id = 123

method = "METHOD_NAME"

confirmation = algod_client.pending_transaction_info(tx_id)

abi_return = app_manager.get_abi_return(confirmation, method)

static decode_app_state(state: list[dict[str, Any]]) → dict[str, algokit_utils.models.application.AppState]

Decode application state from raw format.

app_manager = AppManager(algod_client)

app_id = 123

state = app_manager.get_global_state(app_id)

decoded_state = app_manager.decode_app_state(state)

static replace_template_variables(program: str, template_values: algokit_utils.models.state.TealTemplateParams) → str

Replace template variables in TEAL code.

app_manager = AppManager(algod_client)

app_id = 123

program = "RETURN 1"

template_values = {"TMPL_UPDATABLE": True, "TMPL_DELETABLE": True}

updated_program = app_manager.replace_template_variables(program, template_values)

static replace_teal_template_deploy_time_control_params(teal_template_code: str, params: collections.abc.Mapping[str, bool | None]) → str

Replace deploy-time control parameters in TEAL template.

app_manager = AppManager(algod_client)

app_id = 123

teal_template_code = "RETURN 1"

params = {"TMPL_UPDATABLE": True, "TMPL_DELETABLE": True}

updated_teal_code = app_manager.replace_teal_template_deploy_time_control_params(

teal_template_code, params
)

static strip_teal_comments(teal_code: str) → str

Strip comments from TEAL code.

app_manager = AppManager(algod_client)

teal_code = "RETURN 1"

stripped_teal_code = app_manager.strip_teal_comments(teal_code)