Skip to content

AppManager

@algorandfoundation/algokit-utils / types/app-manager / AppManager

types/app-manager.AppManager

Allows management of application information.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new AppManager(algod): AppManager

Creates an AppManager

Parameters

NameTypeDescription
algodAlgodClientAn algod instance

Returns

AppManager

Defined in

src/types/app-manager.ts:106

Properties

_algod

Private _algod: AlgodClient

Defined in

src/types/app-manager.ts:99


_compilationResults

Private _compilationResults: Record<string, CompiledTeal> = {}

Defined in

src/types/app-manager.ts:100

Methods

compileTeal

compileTeal(tealCode): Promise<CompiledTeal>

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.

Parameters

NameTypeDescription
tealCodestringThe TEAL code

Returns

Promise<CompiledTeal>

The information about the compiled file

Example

const compiled = await appManager.compileTeal(tealProgram);

Defined in

src/types/app-manager.ts:125


compileTealTemplate

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

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

Parameters

NameTypeDescription
tealTemplateCodestringThe TEAL logic to compile
templateParams?TealTemplateParamsAny parameters to replace in the .teal file before compiling
deploymentMetadata?ObjectThe deployment metadata the app will be deployed with
deploymentMetadata.deletable?boolean-
deploymentMetadata.updatable?boolean-

Returns

Promise<CompiledTeal>

The information about the compiled code

Example

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

Defined in

src/types/app-manager.ts:161


getBoxNames

getBoxNames(appId): Promise<BoxName[]>

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

Parameters

NameTypeDescription
appIdbigintThe ID of the app return box names for

Returns

Promise<BoxName[]>

The current box names

Example

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

Defined in

src/types/app-manager.ts:263


getBoxValue

getBoxValue(appId, boxName): Promise<Uint8Array>

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

Parameters

NameTypeDescription
appIdbigintThe ID of the app return box names for
boxNameBoxName | BoxIdentifierThe name of the box to return either as a string, binary array or BoxName

Returns

Promise<Uint8Array>

The current box value as a byte array

Example

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

Defined in

src/types/app-manager.ts:284


getBoxValueFromABIType

getBoxValueFromABIType(request): Promise<ABIValue>

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

Parameters

NameTypeDescription
requestBoxValueRequestParamsThe parameters for the box value request

Returns

Promise<ABIValue>

The current box value as an ABI value

Example

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

Defined in

src/types/app-manager.ts:314


getBoxValues

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

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

Parameters

NameTypeDescription
appIdbigintThe ID of the app return box names for
boxNames(BoxName | BoxIdentifier)[]The names of the boxes to return either as a string, binary array or BoxName

Returns

Promise<Uint8Array[]>

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

Example

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

Defined in

src/types/app-manager.ts:301


getBoxValuesFromABIType

getBoxValuesFromABIType(request): Promise<ABIValue[]>

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

Parameters

NameTypeDescription
requestBoxValuesRequestParamsThe parameters for the box value request

Returns

Promise<ABIValue[]>

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

Example

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

Defined in

src/types/app-manager.ts:329


getById

getById(appId): Promise<AppInformation>

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

Parameters

NameTypeDescription
appIdbigintThe ID of the app

Returns

Promise<AppInformation>

The app information

Example

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

Defined in

src/types/app-manager.ts:202


getCompilationResult

getCompilationResult(tealCode): undefined | CompiledTeal

Returns a previous compilation result.

Parameters

NameTypeDescription
tealCodestringThe TEAL code

Returns

undefined | CompiledTeal

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

Example

const compiled = appManager.getCompilationResult(tealProgram);

Defined in

src/types/app-manager.ts:187


getGlobalState

getGlobalState(appId): Promise<AppState>

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

Parameters

NameTypeDescription
appIdbigintThe ID of the app to return global state for

Returns

Promise<AppState>

The current global state for the given app

Example

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

Defined in

src/types/app-manager.ts:229


getLocalState

getLocalState(appId, address): Promise<AppState>

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

Parameters

NameTypeDescription
appIdbigintThe ID of the app to return local state for
addressstring | AddressThe string address of the account to get local state for the given app

Returns

Promise<AppState>

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

Example

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

Defined in

src/types/app-manager.ts:244


decodeAppState

decodeAppState(state): AppState

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.

Parameters

NameTypeDescription
state{ key: Uint8Array ; value: TealValue | EvalDelta }[]A global-state, local-state, global-state-deltas or local-state-deltas

Returns

AppState

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

Example

const stateValues = AppManager.decodeAppState(state);

Defined in

src/types/app-manager.ts:361


getABIReturn

getABIReturn(confirmation, method): undefined | ABIReturn

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

Parameters

NameTypeDescription
confirmationundefined | PendingTransactionResponseThe transaction confirmation from algod
methodundefined | ABIMethodThe ABI method

Returns

undefined | ABIReturn

The return value for the method call

Example

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

Defined in

src/types/app-manager.ts:414


getBoxReference

getBoxReference(boxId): BoxReference

Returns a algosdk.BoxReference given a BoxIdentifier or BoxReference.

Parameters

NameTypeDescription
boxIdBoxIdentifier | BoxReferenceThe box to return a reference for

Returns

BoxReference

The box reference ready to pass into a algosdk.Transaction

Example

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

Defined in

src/types/app-manager.ts:343


replaceTealTemplateDeployTimeControlParams

replaceTealTemplateDeployTimeControlParams(tealTemplateCode, params): string

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.

Parameters

NameTypeDescription
tealTemplateCodestringThe TEAL template code to substitute
paramsObjectThe deploy-time deployment control parameter value to replace
params.deletable?boolean-
params.updatable?boolean-

Returns

string

The replaced TEAL code

Example

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

Defined in

src/types/app-manager.ts:448


replaceTealTemplateParams

replaceTealTemplateParams(tealTemplateCode, templateParams?): string

Performs template substitution of a teal file.

Looks for TMPL_{parameter} for template replacements.

Parameters

NameTypeDescription
tealTemplateCodestringThe TEAL template code to make parameter replacements in
templateParams?TealTemplateParamsAny parameters to replace in the teal code

Returns

string

The TEAL code with replacements

Example

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

Defined in

src/types/app-manager.ts:483


stripTealComments

stripTealComments(tealCode): string

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

Parameters

NameTypeDescription
tealCodestringThe TEAL logic to strip

Returns

string

The TEAL without comments

Example

const stripped = AppManager.stripTealComments(tealProgram);

Defined in

src/types/app-manager.ts:522