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
Section titled “Table of contents”Constructors
Section titled “Constructors”Properties
Section titled “Properties”- _appAddress
- _appId
- _appName
- _approvalSourceMap
- _clearSourceMap
- _creator
- algod
- appSpec
- deployTimeParams
- existingDeployments
- indexer
- params
- sender
Methods
Section titled “Methods”- call
- callOfType
- clearState
- closeOut
- compile
- create
- delete
- deploy
- exportSourceMaps
- exposeLogicError
- fundAppAccount
- getABIMethod
- getABIMethodParams
- getABIMethodSignature
- getAppReference
- getBoxNames
- getBoxValue
- getBoxValueFromABIType
- getBoxValues
- getBoxValuesFromABIType
- getCallArgs
- getGlobalState
- getLocalState
- importSourceMaps
- optIn
- update
Constructors
Section titled “Constructors”constructor
Section titled “constructor”• new ApplicationClient(appDetails, algod): ApplicationClient
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
appDetails | AppSpecAppDetails | The details of the app |
algod | AlgodClient | An algod instance |
Returns
Section titled “Returns”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
Section titled “Defined in”Properties
Section titled “Properties”_appAddress
Section titled “_appAddress”• Private _appAddress: string
Defined in
Section titled “Defined in”_appId
Section titled “_appId”• Private _appId: number | bigint
Defined in
Section titled “Defined in”_appName
Section titled “_appName”• Private _appName: string
Defined in
Section titled “Defined in”_approvalSourceMap
Section titled “_approvalSourceMap”• Private _approvalSourceMap: undefined | ProgramSourceMap
Defined in
Section titled “Defined in”_clearSourceMap
Section titled “_clearSourceMap”• Private _clearSourceMap: undefined | ProgramSourceMap
Defined in
Section titled “Defined in”_creator
Section titled “_creator”• Private _creator: undefined | string
Defined in
Section titled “Defined in”• Private algod: AlgodClient
Defined in
Section titled “Defined in”appSpec
Section titled “appSpec”• Private appSpec: AppSpec
Defined in
Section titled “Defined in”deployTimeParams
Section titled “deployTimeParams”• Private Optional deployTimeParams: TealTemplateParams
Defined in
Section titled “Defined in”existingDeployments
Section titled “existingDeployments”• Private existingDeployments: undefined | AppLookup
Defined in
Section titled “Defined in”indexer
Section titled “indexer”• Private Optional indexer: IndexerClient
Defined in
Section titled “Defined in”params
Section titled “params”• Private params: undefined | SuggestedParams
Defined in
Section titled “Defined in”sender
Section titled “sender”• Private sender: undefined | SendTransactionFrom
Defined in
Section titled “Defined in”Methods
Section titled “Methods”▸ call(call?): Promise<AppCallTransactionResult>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
call? | AppClientCallParams | The call details. |
Returns
Section titled “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
Section titled “Defined in”callOfType
Section titled “callOfType”▸ callOfType(call?, callType): Promise<AppCallTransactionResult>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
call | AppClientCallParams | The call details. |
callType | "no_op" | "opt_in" | "close_out" | "clear_state" | "delete_application" | NoOpOC | OptInOC | CloseOutOC | ClearStateOC | DeleteApplicationOC | The call type |
Returns
Section titled “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
Section titled “Defined in”clearState
Section titled “clearState”▸ clearState(call?): Promise<AppCallTransactionResult>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
call? | AppClientClearStateParams | The call details. |
Returns
Section titled “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
Section titled “Defined in”closeOut
Section titled “closeOut”▸ closeOut(call?): Promise<AppCallTransactionResult>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
call? | AppClientCallParams | The call details. |
Returns
Section titled “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
Section titled “Defined in”compile
Section titled “compile”▸ compile(compilation?): Promise<{ approvalCompiled: CompiledTeal ; clearCompiled: CompiledTeal }>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
compilation? | AppClientCompilationParams | The deploy-time parameters for the compilation |
Returns
Section titled “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
Section titled “Defined in”create
Section titled “create”▸ create(create?): Promise<{ appAddress: string ; appId: number | bigint ; compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation?: PendingTransactionResponse ; confirmations?: PendingTransactionResponse[] ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] }>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
create? | AppClientCreateParams | The parameters to create the app with |
Returns
Section titled “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
Section titled “Defined in”delete
Section titled “delete”▸ delete(call?): Promise<AppCallTransactionResult>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
call? | AppClientCallParams | The call details. |
Returns
Section titled “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
Section titled “Defined in”deploy
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
deploy? | AppClientDeployParams | Deployment details |
Returns
Section titled “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
Section titled “Defined in”exportSourceMaps
Section titled “exportSourceMaps”▸ exportSourceMaps(): AppSourceMaps
Export the current source maps for the app.
Returns
Section titled “Returns”The source maps
Defined in
Section titled “Defined in”exposeLogicError
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
e | Error | The error to parse |
isClear? | boolean | Whether or not the code was running the clear state program |
Returns
Section titled “Returns”Error
The new error, or if there was no logic error or source map then the wrapped error with source details
Defined in
Section titled “Defined in”fundAppAccount
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
fund | AlgoAmount | FundAppAccountParams | The parameters for the funding or the funding amount |
Returns
Section titled “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
Section titled “Defined in”getABIMethod
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
method | string | Either the name of the method or the ABI method spec definition string |
Returns
Section titled “Returns”undefined | ABIMethod
The ABI method for the given method
Defined in
Section titled “Defined in”getABIMethodParams
Section titled “getABIMethodParams”▸ getABIMethodParams(method): undefined | ABIMethodParams
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
method | string | Either the name of the method or the ABI method spec definition string |
Returns
Section titled “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
Section titled “Defined in”getABIMethodSignature
Section titled “getABIMethodSignature”▸ getABIMethodSignature(method): string
Parameters
Section titled “Parameters”| Name | Type |
|---|---|
method | ABIMethodParams | ABIMethod |
Returns
Section titled “Returns”string
Defined in
Section titled “Defined in”getAppReference
Section titled “getAppReference”▸ getAppReference(): Promise<AppReference | AppMetadata>
Returns
Section titled “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
Section titled “Defined in”getBoxNames
Section titled “getBoxNames”▸ getBoxNames(): Promise<BoxName[]>
Returns the names of all current boxes for the current app.
Returns
Section titled “Returns”Promise<BoxName[]>
The names of the boxes
Defined in
Section titled “Defined in”getBoxValue
Section titled “getBoxValue”▸ getBoxValue(name): Promise<Uint8Array>
Returns the value of the given box for the current app.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
name | string | Uint8Array | BoxName | The name of the box to return either as a string, binary array or BoxName |
Returns
Section titled “Returns”Promise<Uint8Array>
The current box value as a byte array
Defined in
Section titled “Defined in”getBoxValueFromABIType
Section titled “getBoxValueFromABIType”▸ getBoxValueFromABIType(name, type): Promise<ABIValue>
Returns the value of the given box for the current app.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
name | string | Uint8Array | BoxName | The name of the box to return either as a string, binary array or BoxName |
type | ABIType |
Returns
Section titled “Returns”Promise<ABIValue>
The current box value as a byte array
Defined in
Section titled “Defined in”getBoxValues
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
filter? | (name: BoxName) => boolean | Optional filter to filter which boxes’ values are returned |
Returns
Section titled “Returns”Promise<{ name: BoxName ; value: Uint8Array }[]>
The (name, value) pair of the boxes with values as raw byte arrays
Defined in
Section titled “Defined in”getBoxValuesFromABIType
Section titled “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
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
type | ABIType | The ABI type to decode the values with |
filter? | (name: BoxName) => boolean | Optional filter to filter which boxes’ values are returned |
Returns
Section titled “Returns”Promise<{ name: BoxName ; value: ABIValue }[]>
The (name, value) pair of the boxes with values as the ABI Value
Defined in
Section titled “Defined in”getCallArgs
Section titled “getCallArgs”▸ getCallArgs(args, sender): Promise<undefined | AppCallArgs>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
args | undefined | AppClientCallArgs | The call args specific to this application client |
sender | SendTransactionFrom | The sender of this call. Will be used to fetch any default argument values if applicable |
Returns
Section titled “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
Section titled “Defined in”getGlobalState
Section titled “getGlobalState”▸ getGlobalState(): Promise<AppState>
Returns global state for the current app.
Returns
Section titled “Returns”Promise<AppState>
The global state
Defined in
Section titled “Defined in”getLocalState
Section titled “getLocalState”▸ getLocalState(account): Promise<AppState>
Returns local state for the given account / account address.
Parameters
Section titled “Parameters”| Name | Type |
|---|---|
account | string | SendTransactionFrom |
Returns
Section titled “Returns”Promise<AppState>
The global state
Defined in
Section titled “Defined in”importSourceMaps
Section titled “importSourceMaps”▸ importSourceMaps(sourceMaps): void
Import source maps for the app.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
sourceMaps | AppSourceMaps | The source maps to import |
Returns
Section titled “Returns”void
Defined in
Section titled “Defined in”▸ optIn(call?): Promise<AppCallTransactionResult>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
call? | AppClientCallParams | The call details. |
Returns
Section titled “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
Section titled “Defined in”update
Section titled “update”▸ update(update?): Promise<{ compiledApproval: CompiledTeal ; compiledClear: CompiledTeal ; confirmation?: PendingTransactionResponse ; confirmations?: PendingTransactionResponse[] ; return?: ABIReturn ; transaction: Transaction ; transactions: Transaction[] }>
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
update? | AppClientUpdateParams | The parameters to update the app with |
Returns
Section titled “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.