Skip to content

AppManager

Defined in: algokit-utils-ts/src/types/app-manager.ts:138

Allows management of application information.

new AppManager(algod): AppManager

Defined in: algokit-utils-ts/src/types/app-manager.ts:146

Creates an AppManager

AlgodClient

An algod instance

AppManager

compileTeal(tealCode): Promise<CompiledTeal>

Defined in: algokit-utils-ts/src/types/app-manager.ts:165

Compiles the given TEAL using algod and returns the result, including source map.

The result of this compilation is also cached keyed by the TEAL code so it can be retrieved via getCompilationResult.

This function is re-entrant; it will only compile the same code once.

string

The TEAL code

Promise<CompiledTeal>

The information about the compiled file

const compiled = await appManager.compileTeal(tealProgram)

compileTealTemplate(tealTemplateCode, templateParams?, deploymentMetadata?): Promise<CompiledTeal>

Defined in: algokit-utils-ts/src/types/app-manager.ts:201

Performs template substitution of a teal template and compiles it, returning the compiled result.

Looks for TMPL_{parameter} for template replacements and replaces AlgoKit deploy-time control parameters if deployment metadata is specified.

  • TMPL_UPDATABLE for updatability / immutability control
  • TMPL_DELETABLE for deletability / permanence control

string

The TEAL logic to compile

TealTemplateParams

Any parameters to replace in the .teal file before compiling

The deployment metadata the app will be deployed with

boolean

boolean

Promise<CompiledTeal>

The information about the compiled code

const compiled = await appManager.compileTealTemplate(tealTemplate, { TMPL_APP_ID: 12345n }, { updatable: true, deletable: false })

getBoxNames(appId): Promise<BoxName[]>

Defined in: algokit-utils-ts/src/types/app-manager.ts:305

Returns the names of the current boxes for the given app.

bigint

The ID of the app return box names for

Promise<BoxName[]>

The current box names

const boxNames = await appManager.getBoxNames(12353n);

getBoxValue(appId, boxName): Promise<Uint8Array<ArrayBufferLike>>

Defined in: algokit-utils-ts/src/types/app-manager.ts:326

Returns the value of the given box name for the given app.

bigint

The ID of the app return box names for

BoxIdentifier | BoxName

The name of the box to return either as a string, binary array or BoxName

Promise<Uint8Array<ArrayBufferLike>>

The current box value as a byte array

const boxValue = await appManager.getBoxValue(12353n, 'boxName');

getBoxValueFromABIType(request): Promise<ABIValue>

Defined in: algokit-utils-ts/src/types/app-manager.ts:356

Returns the value of the given box name for the given app decoded based on the given ABI type.

BoxValueRequestParams

The parameters for the box value request

Promise<ABIValue>

The current box value as an ABI value

const boxValue = await appManager.getBoxValueFromABIType({ appId: 12353n, boxName: 'boxName', type: new ABIUintType(32) });

getBoxValues(appId, boxNames): Promise<Uint8Array<ArrayBufferLike>[]>

Defined in: algokit-utils-ts/src/types/app-manager.ts:343

Returns the value of the given box names for the given app.

bigint

The ID of the app return box names for

(BoxIdentifier | BoxName)[]

The names of the boxes to return either as a string, binary array or BoxName

Promise<Uint8Array<ArrayBufferLike>[]>

The current box values as a byte array in the same order as the passed in box names

const boxValues = await appManager.getBoxValues(12353n, ['boxName1', 'boxName2']);

getBoxValuesFromABIType(request): Promise<ABIValue[]>

Defined in: algokit-utils-ts/src/types/app-manager.ts:371

Returns the value of the given box names for the given app decoded based on the given ABI type.

BoxValuesRequestParams

The parameters for the box value request

Promise<ABIValue[]>

The current box values as an ABI value in the same order as the passed in box names

const boxValues = await appManager.getBoxValuesFromABIType({ appId: 12353n, boxNames: ['boxName1', 'boxName2'], type: new ABIUintType(32) });

getById(appId): Promise<AppInformation>

Defined in: algokit-utils-ts/src/types/app-manager.ts:242

Returns the current app information for the app with the given ID.

bigint

The ID of the app

Promise<AppInformation>

The app information

const appInfo = await appManager.getById(12353n);

getCompilationResult(tealCode): CompiledTeal | undefined

Defined in: algokit-utils-ts/src/types/app-manager.ts:227

Returns a previous compilation result.

string

The TEAL code

CompiledTeal | undefined

The information about the previously compiled file or undefined if that TEAL code wasn’t previously compiled

const compiled = appManager.getCompilationResult(tealProgram)

getGlobalState(appId): Promise<AppState>

Defined in: algokit-utils-ts/src/types/app-manager.ts:271

Returns the current global state values for the given app ID and account address

bigint

The ID of the app to return global state for

Promise<AppState>

The current global state for the given app

const globalState = await appManager.getGlobalState(12353n);

getLocalState(appId, address): Promise<AppState>

Defined in: algokit-utils-ts/src/types/app-manager.ts:286

Returns the current local state values for the given app ID and account address

bigint

The ID of the app to return local state for

string | Address

The string address of the account to get local state for the given app

Promise<AppState>

The current local state for the given (app, account) combination

const localState = await appManager.getLocalState(12353n, 'ACCOUNTADDRESS');

static decodeAppState(state): AppState

Defined in: algokit-utils-ts/src/types/app-manager.ts:403

Converts an array of global/local state values from the algod api to a more friendly generic object keyed by the UTF-8 value of the key.

object[]

A global-state, local-state, global-state-deltas or local-state-deltas

AppState

An object keyeed by the UTF-8 representation of the key with various parsings of the values

const stateValues = AppManager.decodeAppState(state);

static getABIReturn(confirmation, method): ABIReturn | undefined

Defined in: algokit-utils-ts/src/types/app-manager.ts:456

Returns any ABI return values for the given app call arguments and transaction confirmation.

PendingTransactionResponse | undefined

The transaction confirmation from algod

ABIMethod | undefined

The ABI method

ABIReturn | undefined

The return value for the method call

const returnValue = AppManager.getABIReturn(confirmation, ABIMethod.fromSignature('hello(string)void'));

static getBoxReference(boxId): BoxReference

Defined in: algokit-utils-ts/src/types/app-manager.ts:385

Returns a algosdk.BoxReference given a BoxIdentifier or BoxReference.

BoxReference | BoxIdentifier

The box to return a reference for

BoxReference

The box reference ready to pass into a algosdk.Transaction

const boxRef = AppManager.getBoxReference('boxName');

replaceTealTemplateDeployTimeControlParams()

Section titled “replaceTealTemplateDeployTimeControlParams()”

static replaceTealTemplateDeployTimeControlParams(tealTemplateCode, params): string

Defined in: algokit-utils-ts/src/types/app-manager.ts:490

Replaces AlgoKit deploy-time deployment control parameters within the given TEAL template code.

  • TMPL_UPDATABLE for updatability / immutability control
  • TMPL_DELETABLE for deletability / permanence control

Note: If these values are defined, but the corresponding TMPL_* value isn’t in the teal code it will throw an exception.

string

The TEAL template code to substitute

The deploy-time deployment control parameter value to replace

boolean

boolean

string

The replaced TEAL code

const tealCode = AppManager.replaceTealTemplateDeployTimeControlParams(tealTemplate, { updatable: true, deletable: false });

static replaceTealTemplateParams(tealTemplateCode, templateParams?): string

Defined in: algokit-utils-ts/src/types/app-manager.ts:525

Performs template substitution of a teal file.

Looks for TMPL_{parameter} for template replacements.

string

The TEAL template code to make parameter replacements in

TealTemplateParams

Any parameters to replace in the teal code

string

The TEAL code with replacements

const tealCode = AppManager.replaceTealTemplateParams(tealTemplate, { TMPL_APP_ID: 12345n });

static stripTealComments(tealCode): string

Defined in: algokit-utils-ts/src/types/app-manager.ts:564

Remove comments from TEAL code (useful to reduce code size before compilation).

string

The TEAL logic to strip

string

The TEAL without comments

const stripped = AppManager.stripTealComments(tealProgram);