Skip to content

ApplicationClient

@algorandfoundation/algokit-utils / types/app-client / ApplicationClient

types/app-client.ApplicationClient

Deprecated

Use AppClient instead e.g. via algorand.client.getAppClientById or algorand.client.getAppClientByCreatorAndName. If you want to create or deploy then use AppFactory e.g. via algorand.client.getAppFactory, which will in turn give you an AppClient instance against the created/deployed app to make other calls.

Application client - a class that wraps an ARC-0032 app spec and provides high productivity methods to deploy and call the app

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ApplicationClient(appDetails, algod): ApplicationClient

Parameters

NameTypeDescription
appDetailsAppSpecAppDetailsThe details of the app
algodAlgodClientAn algod instance

Returns

ApplicationClient

Deprecated

Use AppClient instead e.g. via algorand.client.getAppClientById or algorand.client.getAppClientByCreatorAndName. If you want to create or deploy then use AppFactory e.g. via algorand.client.getAppFactory, which will in turn give you an AppClient instance against the created/deployed app to make other calls.

Create a new ApplicationClient instance

Defined in

src/types/app-client.ts:1821

Properties

_appAddress

Private _appAddress: string

Defined in

src/types/app-client.ts:1804


_appId

Private _appId: number | bigint

Defined in

src/types/app-client.ts:1803


_appName

Private _appName: string

Defined in

src/types/app-client.ts:1806


_approvalSourceMap

Private _approvalSourceMap: undefined | ProgramSourceMap

Defined in

src/types/app-client.ts:1808


_clearSourceMap

Private _clearSourceMap: undefined | ProgramSourceMap

Defined in

src/types/app-client.ts:1809


_creator

Private _creator: undefined | string

Defined in

src/types/app-client.ts:1805


algod

Private algod: AlgodClient

Defined in

src/types/app-client.ts:1795


appSpec

Private appSpec: AppSpec

Defined in

src/types/app-client.ts:1797


deployTimeParams

Private Optional deployTimeParams: TealTemplateParams

Defined in

src/types/app-client.ts:1801


existingDeployments

Private existingDeployments: undefined | AppLookup

Defined in

src/types/app-client.ts:1800


indexer

Private Optional indexer: IndexerClient

Defined in

src/types/app-client.ts:1796


params

Private params: undefined | SuggestedParams

Defined in

src/types/app-client.ts:1799


sender

Private sender: undefined | SendTransactionFrom

Defined in

src/types/app-client.ts:1798

Methods

call

call(call?): Promise<AppCallTransactionResult>

Parameters

NameTypeDescription
call?AppClientCallParamsThe call details.

Returns

Promise<AppCallTransactionResult>

The result of the call

Deprecated

Use appClient.send.call or appClient.createTransaction.call from an AppClient instance instead.

Issues a no_op (normal) call to the app.

Defined in

src/types/app-client.ts:2144


callOfType

callOfType(call?, callType): Promise<AppCallTransactionResult>

Parameters

NameTypeDescription
callAppClientCallParamsThe call details.
callType"no_op" | "opt_in" | "close_out" | "clear_state" | "delete_application" | NoOpOC | OptInOC | CloseOutOC | ClearStateOC | DeleteApplicationOCThe call type

Returns

Promise<AppCallTransactionResult>

The result of the call

Deprecated

Use appClient.send.call or appClient.createTransaction.call from an AppClient instance instead.

Issues a call to the app with the given call type.

Defined in

src/types/app-client.ts:2226


clearState

clearState(call?): Promise<AppCallTransactionResult>

Parameters

NameTypeDescription
call?AppClientClearStateParamsThe call details.

Returns

Promise<AppCallTransactionResult>

The result of the call

Deprecated

Use appClient.send.clearState or appClient.createTransaction.clearState from an AppClient instance instead.

Issues a clear_state call to the app.

Defined in

src/types/app-client.ts:2203


closeOut

closeOut(call?): Promise<AppCallTransactionResult>

Parameters

NameTypeDescription
call?AppClientCallParamsThe call details.

Returns

Promise<AppCallTransactionResult>

The result of the call

Deprecated

Use appClient.send.closeOut or appClient.createTransaction.closeOut from an AppClient instance instead.

Issues a close_out call to the app.

Defined in

src/types/app-client.ts:2192


compile

compile(compilation?): Promise<{ approvalCompiled: CompiledTeal ; clearCompiled: CompiledTeal }>

Parameters

NameTypeDescription
compilation?AppClientCompilationParamsThe deploy-time parameters for the compilation

Returns

Promise<{ approvalCompiled: CompiledTeal ; clearCompiled: CompiledTeal }>

The compiled approval and clear state programs

Deprecated

Use AppClient.compile() instead.

Compiles the approval and clear state programs and sets up the source map.

Defined in

src/types/app-client.ts:1860


create

create(create?): Promise<{ appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation?: PendingTransactionResponse ; confirmations?: PendingTransactionResponse[] ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] }>

Parameters

NameTypeDescription
create?AppClientCreateParamsThe parameters to create the app with

Returns

Promise<{ appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation?: PendingTransactionResponse ; confirmations?: PendingTransactionResponse[] ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] }>

The details of the created app, or the transaction to create it if skipSending and the compilation result

Deprecated

Use create from an AppFactory instance instead.

Creates a smart contract app, returns the details of the created app.

Defined in

src/types/app-client.ts:2039


delete

delete(call?): Promise<AppCallTransactionResult>

Parameters

NameTypeDescription
call?AppClientCallParamsThe call details.

Returns

Promise<AppCallTransactionResult>

The result of the call

Deprecated

Use appClient.send.delete or appClient.createTransaction.delete from an AppClient instance instead.

Issues a delete_application call to the app.

Defined in

src/types/app-client.ts:2214


deploy

deploy(deploy?): Promise<Partial<AppCompilationResult> & AppMetadata & { operationPerformed: "nothing" } | { appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation: PendingTransactionResponse ; confirmations: PendingTransactionResponse[] ; createdMetadata: AppDeployMetadata ; createdRound: number ; deletable?: boolean ; deleted: boolean ; name: string ; operationPerformed: "update" | "create" ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] ; updatable?: boolean ; updatedRound: number ; version: string } | { appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation: PendingTransactionResponse ; confirmations: PendingTransactionResponse[] ; createdMetadata: AppDeployMetadata ; createdRound: number ; deletable?: boolean ; deleteResult: ConfirmedTransactionResult ; deleteReturn?: ABIReturn ; deleted: boolean ; name: string ; operationPerformed: "replace" ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] ; updatable?: boolean ; updatedRound: number ; version: string }>

Parameters

NameTypeDescription
deploy?AppClientDeployParamsDeployment details

Returns

Promise<Partial<AppCompilationResult> & AppMetadata & { operationPerformed: "nothing" } | { appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation: PendingTransactionResponse ; confirmations: PendingTransactionResponse[] ; createdMetadata: AppDeployMetadata ; createdRound: number ; deletable?: boolean ; deleted: boolean ; name: string ; operationPerformed: "update" | "create" ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] ; updatable?: boolean ; updatedRound: number ; version: string } | { appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation: PendingTransactionResponse ; confirmations: PendingTransactionResponse[] ; createdMetadata: AppDeployMetadata ; createdRound: number ; deletable?: boolean ; deleteResult: ConfirmedTransactionResult ; deleteReturn?: ABIReturn ; deleted: boolean ; name: string ; operationPerformed: "replace" ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] ; updatable?: boolean ; updatedRound: number ; version: string }>

The metadata and transaction result(s) of the deployment, or just the metadata if it didn’t need to issue transactions

Deprecated

Use deploy from an AppFactory instance instead.

Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.

To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md

Note: if there is a breaking state schema change to an existing app (and onSchemaBreak is set to 'replace') the existing app will be deleted and re-created.

Note: if there is an update (different TEAL code) to an existing app (and onUpdate is set to 'replace') the existing app will be deleted and re-created.

Defined in

src/types/app-client.ts:1928


exportSourceMaps

exportSourceMaps(): AppSourceMaps

Export the current source maps for the app.

Returns

AppSourceMaps

The source maps

Defined in

src/types/app-client.ts:1893


exposeLogicError

exposeLogicError(e, isClear?): Error

Takes an error that may include a logic error from a smart contract call and re-exposes the error to include source code information via the source map. This is automatically used within ApplicationClient but if you pass skipSending: true e.g. if doing a group transaction then you can use this in a try/catch block to get better debugging information.

Parameters

NameTypeDescription
eErrorThe error to parse
isClear?booleanWhether or not the code was running the clear state program

Returns

Error

The new error, or if there was no logic error or source map then the wrapped error with source details

Defined in

src/types/app-client.ts:2548


fundAppAccount

fundAppAccount(fund): Promise<SendTransactionResult | { confirmation: PendingTransactionResponse ; confirmations: PendingTransactionResponse[] ; groupId: string ; returns?: ABIReturn[] ; transaction: Transaction ; transactions: Transaction[] ; txIds: string[] } & { transactions: Transaction[] }>

Funds Algo into the app account for this app.

Parameters

NameTypeDescription
fundAlgoAmount | FundAppAccountParamsThe parameters for the funding or the funding amount

Returns

Promise<SendTransactionResult | { confirmation: PendingTransactionResponse ; confirmations: PendingTransactionResponse[] ; groupId: string ; returns?: ABIReturn[] ; transaction: Transaction ; transactions: Transaction[] ; txIds: string[] } & { transactions: Transaction[] }>

The result of the funding

Defined in

src/types/app-client.ts:2265


getABIMethod

getABIMethod(method): undefined | ABIMethod

Returns the ABI Method for the given method name string for the app represented by this application client instance

Parameters

NameTypeDescription
methodstringEither the name of the method or the ABI method spec definition string

Returns

undefined | ABIMethod

The ABI method for the given method

Defined in

src/types/app-client.ts:2506


getABIMethodParams

getABIMethodParams(method): undefined | ABIMethodParams

Parameters

NameTypeDescription
methodstringEither the name of the method or the ABI method spec definition string

Returns

undefined | ABIMethodParams

The ABI method params for the given method

Deprecated

Use appClient.getABIMethod instead.

Returns the ABI Method parameters for the given method name string for the app represented by this application client instance

Defined in

src/types/app-client.ts:2484


getABIMethodSignature

getABIMethodSignature(method): string

Parameters

NameType
methodABIMethodParams | ABIMethod

Returns

string

Defined in

src/types/app-client.ts:2564


getAppReference

getAppReference(): Promise<AppReference | AppMetadata>

Returns

Promise<AppReference | AppMetadata>

The app reference, or if deployed using the deploy method, the app metadata too

Deprecated

Use appClient.appId and appClient.appAddress from an AppClient instance instead.

Gets the reference information for the current application instance. appId will be 0 if it can’t find an app.

Defined in

src/types/app-client.ts:2518


getBoxNames

getBoxNames(): Promise<BoxName[]>

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

Returns

Promise<BoxName[]>

The names of the boxes

Defined in

src/types/app-client.ts:2321


getBoxValue

getBoxValue(name): Promise<Uint8Array>

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

Parameters

NameTypeDescription
namestring | Uint8Array | BoxNameThe 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

Defined in

src/types/app-client.ts:2336


getBoxValueFromABIType

getBoxValueFromABIType(name, type): Promise<ABIValue>

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

Parameters

NameTypeDescription
namestring | Uint8Array | BoxNameThe name of the box to return either as a string, binary array or BoxName
typeABIType

Returns

Promise<ABIValue>

The current box value as a byte array

Defined in

src/types/app-client.ts:2352


getBoxValues

getBoxValues(filter?): Promise<{ name: BoxName ; value: Uint8Array }[]>

Returns the values of all current boxes for the current app. Note: This will issue multiple HTTP requests (one per box) and it’s not an atomic operation so values may be out of sync.

Parameters

NameTypeDescription
filter?(name: BoxName) => booleanOptional filter to filter which boxes’ values are returned

Returns

Promise<{ name: BoxName ; value: Uint8Array }[]>

The (name, value) pair of the boxes with values as raw byte arrays

Defined in

src/types/app-client.ts:2368


getBoxValuesFromABIType

getBoxValuesFromABIType(type, filter?): Promise<{ name: BoxName ; value: ABIValue }[]>

Returns the values of all current boxes for the current app decoded using an ABI Type. Note: This will issue multiple HTTP requests (one per box) and it’s not an atomic operation so values may be out of sync.

Parameters

NameTypeDescription
typeABITypeThe ABI type to decode the values with
filter?(name: BoxName) => booleanOptional filter to filter which boxes’ values are returned

Returns

Promise<{ name: BoxName ; value: ABIValue }[]>

The (name, value) pair of the boxes with values as the ABI Value

Defined in

src/types/app-client.ts:2390


getCallArgs

getCallArgs(args, sender): Promise<undefined | AppCallArgs>

Parameters

NameTypeDescription
argsundefined | AppClientCallArgsThe call args specific to this application client
senderSendTransactionFromThe sender of this call. Will be used to fetch any default argument values if applicable

Returns

Promise<undefined | AppCallArgs>

The call args ready to pass into an app call

Deprecated

Use appClient.params.* from an AppClient instance instead.

Returns the arguments for an app call for the given ABI method or raw method specification.

Defined in

src/types/app-client.ts:2414


getGlobalState

getGlobalState(): Promise<AppState>

Returns global state for the current app.

Returns

Promise<AppState>

The global state

Defined in

src/types/app-client.ts:2293


getLocalState

getLocalState(account): Promise<AppState>

Returns local state for the given account / account address.

Parameters

NameType
accountstring | SendTransactionFrom

Returns

Promise<AppState>

The global state

Defined in

src/types/app-client.ts:2307


importSourceMaps

importSourceMaps(sourceMaps): void

Import source maps for the app.

Parameters

NameTypeDescription
sourceMapsAppSourceMapsThe source maps to import

Returns

void

Defined in

src/types/app-client.ts:1910


optIn

optIn(call?): Promise<AppCallTransactionResult>

Parameters

NameTypeDescription
call?AppClientCallParamsThe call details.

Returns

Promise<AppCallTransactionResult>

The result of the call

Deprecated

Use appClient.send.optIn or appClient.createTransaction.optIn from an AppClient instance instead.

Issues a opt_in call to the app.

Defined in

src/types/app-client.ts:2181


update

update(update?): Promise<{ compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation?: PendingTransactionResponse ; confirmations?: PendingTransactionResponse[] ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] }>

Parameters

NameTypeDescription
update?AppClientUpdateParamsThe parameters to update the app with

Returns

Promise<{ compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation?: PendingTransactionResponse ; confirmations?: PendingTransactionResponse[] ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] }>

The transaction send result and the compilation result

Deprecated

Use appClient.send.update or appClient.createTransaction.update from an AppClient instance instead.

Updates the smart contract app.

Defined in

src/types/app-client.ts:2103