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

new ApplicationClient(appDetails, algod): ApplicationClient

NameTypeDescription
appDetailsAppSpecAppDetailsThe details of the app
algodAlgodClientAn algod instance

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

src/types/app-client.ts:1821

Private _appAddress: string

src/types/app-client.ts:1804


Private _appId: number | bigint

src/types/app-client.ts:1803


Private _appName: string

src/types/app-client.ts:1806


Private _approvalSourceMap: undefined | ProgramSourceMap

src/types/app-client.ts:1808


Private _clearSourceMap: undefined | ProgramSourceMap

src/types/app-client.ts:1809


Private _creator: undefined | string

src/types/app-client.ts:1805


Private algod: AlgodClient

src/types/app-client.ts:1795


Private appSpec: AppSpec

src/types/app-client.ts:1797


Private Optional deployTimeParams: TealTemplateParams

src/types/app-client.ts:1801


Private existingDeployments: undefined | AppLookup

src/types/app-client.ts:1800


Private Optional indexer: IndexerClient

src/types/app-client.ts:1796


Private params: undefined | SuggestedParams

src/types/app-client.ts:1799


Private sender: undefined | SendTransactionFrom

src/types/app-client.ts:1798

call(call?): Promise<AppCallTransactionResult>

NameTypeDescription
call?AppClientCallParamsThe call details.

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.

src/types/app-client.ts:2144


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

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

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.

src/types/app-client.ts:2226


clearState(call?): Promise<AppCallTransactionResult>

NameTypeDescription
call?AppClientClearStateParamsThe call details.

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.

src/types/app-client.ts:2203


closeOut(call?): Promise<AppCallTransactionResult>

NameTypeDescription
call?AppClientCallParamsThe call details.

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.

src/types/app-client.ts:2192


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

NameTypeDescription
compilation?AppClientCompilationParamsThe deploy-time parameters for the compilation

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.

src/types/app-client.ts:1860


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

NameTypeDescription
create?AppClientCreateParamsThe parameters to create the app with

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.

src/types/app-client.ts:2039


delete(call?): Promise<AppCallTransactionResult>

NameTypeDescription
call?AppClientCallParamsThe call details.

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.

src/types/app-client.ts:2214


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 }>

NameTypeDescription
deploy?AppClientDeployParamsDeployment details

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.

src/types/app-client.ts:1928


exportSourceMaps(): AppSourceMaps

Export the current source maps for the app.

AppSourceMaps

The source maps

src/types/app-client.ts:1893


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.

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

Error

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

src/types/app-client.ts:2548


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.

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

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

The result of the funding

src/types/app-client.ts:2265


getABIMethod(method): undefined | ABIMethod

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

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

undefined | ABIMethod

The ABI method for the given method

src/types/app-client.ts:2506


getABIMethodParams(method): undefined | ABIMethodParams

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

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

src/types/app-client.ts:2484


getABIMethodSignature(method): string

NameType
methodABIMethodParams | ABIMethod

string

src/types/app-client.ts:2564


getAppReference(): Promise<AppReference | AppMetadata>

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.

src/types/app-client.ts:2518


getBoxNames(): Promise<BoxName[]>

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

Promise<BoxName[]>

The names of the boxes

src/types/app-client.ts:2321


getBoxValue(name): Promise<Uint8Array>

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

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

Promise<Uint8Array>

The current box value as a byte array

src/types/app-client.ts:2336


getBoxValueFromABIType(name, type): Promise<ABIValue>

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

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

Promise<ABIValue>

The current box value as a byte array

src/types/app-client.ts:2352


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.

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

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

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

src/types/app-client.ts:2368


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.

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

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

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

src/types/app-client.ts:2390


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

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

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.

src/types/app-client.ts:2414


getGlobalState(): Promise<AppState>

Returns global state for the current app.

Promise<AppState>

The global state

src/types/app-client.ts:2293


getLocalState(account): Promise<AppState>

Returns local state for the given account / account address.

NameType
accountstring | SendTransactionFrom

Promise<AppState>

The global state

src/types/app-client.ts:2307


importSourceMaps(sourceMaps): void

Import source maps for the app.

NameTypeDescription
sourceMapsAppSourceMapsThe source maps to import

void

src/types/app-client.ts:1910


optIn(call?): Promise<AppCallTransactionResult>

NameTypeDescription
call?AppClientCallParamsThe call details.

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.

src/types/app-client.ts:2181


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

NameTypeDescription
update?AppClientUpdateParamsThe parameters to update the app with

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.

src/types/app-client.ts:2103