ClientManager
@algorandfoundation/algokit-utils / types/client-manager / ClientManager
types/client-manager.ClientManager
Exposes access to various API clients.
Table of contents
Constructors
Properties
Accessors
Methods
- getAppClientByCreatorAndName
- getAppClientById
- getAppClientByNetwork
- getAppFactory
- getTestNetDispenser
- getTestNetDispenserFromEnvironment
- getTypedAppClientByCreatorAndName
- getTypedAppClientById
- getTypedAppClientByNetwork
- getTypedAppFactory
- isLocalNet
- isMainNet
- isTestNet
- network
- genesisIdIsLocalNet
- getAlgoNodeConfig
- getAlgodClient
- getAlgodClientFromEnvironment
- getAlgodConfigFromEnvironment
- getConfigFromEnvironmentOrLocalNet
- getDefaultLocalNetConfig
- getIndexerClient
- getIndexerClientFromEnvironment
- getIndexerConfigFromEnvironment
- getKmdClient
- getKmdClientFromEnvironment
Constructors
constructor
• new ClientManager(clientsOrConfig
, algorandClient?
): ClientManager
algosdk clients or config for interacting with the official Algorand APIs.
Parameters
Name | Type | Description |
---|---|---|
clientsOrConfig | AlgoConfig | AlgoSdkClients | The clients or config to use |
algorandClient? | AlgorandClient | - |
Returns
Example
const clientManager = new ClientManager({ algod: algodClient });
Example
const clientManager = new ClientManager({ algod: algodClient, indexer: indexerClient, kmd: kmdClient,});
Example
const clientManager = new ClientManager({ algodConfig });
Example
const clientManager = new ClientManager({ algodConfig, indexerConfig, kmdConfig });
Defined in
src/types/client-manager.ts:74
Properties
_algod
• Private
_algod: AlgodClient
Defined in
src/types/client-manager.ts:49
_algorand
• Private
Optional
_algorand: AlgorandClient
Defined in
src/types/client-manager.ts:52
_getNetworkPromise
• Private
_getNetworkPromise: undefined
| Promise
<SuggestedParams
>
Defined in
src/types/client-manager.ts:125
_indexer
• Private
Optional
_indexer: IndexerClient
Defined in
src/types/client-manager.ts:50
_kmd
• Private
Optional
_kmd: KmdClient
Defined in
src/types/client-manager.ts:51
Accessors
algod
• get
algod(): AlgodClient
Returns an algosdk Algod API client.
Returns
AlgodClient
The Algod client
Defined in
src/types/client-manager.ts:93
indexer
• get
indexer(): IndexerClient
Returns an algosdk Indexer API client or throws an error if it’s not been provided.
Returns
IndexerClient
The Indexer client
Throws
Error if no Indexer client is configured
Defined in
src/types/client-manager.ts:102
indexerIfPresent
• get
indexerIfPresent(): undefined
| IndexerClient
Returns an algosdk Indexer API client or undefined
if it’s not been provided.
Returns
undefined
| IndexerClient
The Indexer client or undefined
Defined in
src/types/client-manager.ts:111
kmd
• get
kmd(): KmdClient
Returns an algosdk KMD API client or throws an error if it’s not been provided.
Returns
KmdClient
The KMD client
Throws
Error if no KMD client is configured
Defined in
src/types/client-manager.ts:120
Methods
getAppClientByCreatorAndName
▸ getAppClientByCreatorAndName(params
): Promise
<AppClient
>
Returns a new AppClient
client for managing calls and state for an ARC-32/ARC-56 app.
This method resolves the app ID by looking up the creator address and name
using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
Parameters
Name | Type | Description |
---|---|---|
params | Object | The parameters to create the app client |
params.appLookupCache? | AppLookup | An optional cached app lookup that matches a name to on-chain details; either this is needed or indexer is required to be passed in to this ClientManager on construction. |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name |
params.appSpec | string | Arc56Contract | AppSpec | The ARC-56 or ARC-32 application spec as either: _ Parsed JSON ARC-56 Contract _ Parsed JSON ARC-32 AppSpec * Raw JSON string (in either ARC-56 or ARC-32 format) |
params.approvalSourceMap? | ProgramSourceMap | Optional source map for the approval program |
params.clearSourceMap? | ProgramSourceMap | Optional source map for the clear state program |
params.creatorAddress | string | Address | The address of the creator account for the app |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
params.ignoreCache? | boolean | Whether or not to ignore the AppDeployer lookup cache and force an on-chain lookup, default: use any cached value |
Returns
Promise
<AppClient
>
The AppClient
instance
Example
const appClient = clientManager.getAppClientByCreatorAndName({ appSpec: '{/* ARC-56 or ARC-32 compatible JSON *}', // appId resolved by looking for app ID of named app by this creator creatorAddress: 'CREATORADDRESS',});
Defined in
src/types/client-manager.ts:284
getAppClientById
▸ getAppClientById(params
): AppClient
Returns a new AppClient
client for managing calls and state for an ARC-32/ARC-56 app.
Parameters
Name | Type | Description |
---|---|---|
params | Object | The parameters to create the app client |
params.appId | bigint | The ID of the app instance this client should make calls against. |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name |
params.appSpec | string | Arc56Contract | AppSpec | The ARC-56 or ARC-32 application spec as either: _ Parsed JSON ARC-56 Contract _ Parsed JSON ARC-32 AppSpec * Raw JSON string (in either ARC-56 or ARC-32 format) |
params.approvalSourceMap? | ProgramSourceMap | Optional source map for the approval program |
params.clearSourceMap? | ProgramSourceMap | Optional source map for the clear state program |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
Returns
The AppClient
instance
Example
const appClient = clientManager.getAppClientById({ appSpec: '{/* ARC-56 or ARC-32 compatible JSON *}', appId: 12345n,});
Defined in
src/types/client-manager.ts:307
getAppClientByNetwork
▸ getAppClientByNetwork(params
): Promise
<AppClient
>
Returns a new AppClient
client for managing calls and state for an ARC-56 app.
This method resolves the app ID for the current network based on
pre-determined network-specific app IDs specified in the ARC-56 app spec.
If no IDs are in the app spec or the network isn’t recognised, an error is thrown.
Parameters
Name | Type | Description |
---|---|---|
params | Object | The parameters to create the app client |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name |
params.appSpec | string | Arc56Contract | AppSpec | The ARC-56 or ARC-32 application spec as either: _ Parsed JSON ARC-56 Contract _ Parsed JSON ARC-32 AppSpec * Raw JSON string (in either ARC-56 or ARC-32 format) |
params.approvalSourceMap? | ProgramSourceMap | Optional source map for the approval program |
params.clearSourceMap? | ProgramSourceMap | Optional source map for the clear state program |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
Returns
Promise
<AppClient
>
The AppClient
instance
Example
const appClient = clientManager.getAppClientByNetwork({ appSpec: '{/* ARC-56 or ARC-32 compatible JSON *}', // appId resolved by using ARC-56 spec to find app ID for current network});
Defined in
src/types/client-manager.ts:330
getAppFactory
▸ getAppFactory(params
): AppFactory
Returns a new AppFactory
client
Parameters
Name | Type | Description |
---|---|---|
params | Object | The parameters to create the app factory |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name. |
params.appSpec | string | Arc56Contract | AppSpec | The ARC-56 or ARC-32 application spec as either: _ Parsed JSON ARC-56 Contract _ Parsed JSON ARC-32 AppSpec * Raw JSON string (in either ARC-56 or ARC-32 format) |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
params.deletable? | boolean | Whether or not the contract should have deploy-time permanence control set, undefined = ignore. If specified here will get used in calls to deploy and create calls unless overridden in those calls. Useful if you want to vend multiple contracts from the same factory without specifying this value for each call. |
params.deployTimeParams? | TealTemplateParams | Optional deploy-time TEAL template replacement parameters. If specified here will get used in calls to deploy and create calls unless overridden in those calls. Useful if you want to vend multiple contracts from the same factory without specifying this value for each call. |
params.updatable? | boolean | Whether or not the contract should have deploy-time immutability control set, undefined = ignore. If specified here will get used in calls to deploy and create calls unless overridden in those calls. Useful if you want to vend multiple contracts from the same factory without specifying this value for each call. |
params.version? | string | The version of app that is / will be deployed; defaults to 1.0 |
Returns
The AppFactory
instance
Example
const factory = clientManager.getAppFactory({ appSpec: '{/* ARC-56 or ARC-32 compatible JSON */}',});
Example
const factory = clientManager.getAppFactory({ appSpec: parsedAppSpec_AppSpec_or_Arc56Contract, defaultSender: 'SENDERADDRESS', appName: 'OverriddenAppName', version: '2.0.0', updatable: true, deletable: false, deployTimeParams: { ONE: 1, TWO: 'value' },});
Defined in
src/types/client-manager.ts:261
getTestNetDispenser
▸ getTestNetDispenser(params
): TestNetDispenserApiClient
Returns a TestNet Dispenser API client.
Refer to docs on guidance to obtain an access token.
Parameters
Name | Type | Description |
---|---|---|
params | TestNetDispenserApiClientParams | An object containing parameters for the TestNetDispenserApiClient class. |
Returns
An instance of the TestNetDispenserApiClient class.
Example
const client = clientManager.getTestNetDispenser({ authToken: 'your_auth_token', requestTimeout: 15,});
Defined in
src/types/client-manager.ts:215
getTestNetDispenserFromEnvironment
▸ getTestNetDispenserFromEnvironment(params?
): TestNetDispenserApiClient
Returns a TestNet Dispenser API client, loading the auth token from process.env.ALGOKIT_DISPENSER_ACCESS_TOKEN
.
Refer to docs on guidance to obtain an access token.
Parameters
Name | Type | Description |
---|---|---|
params? | Omit <TestNetDispenserApiClientParams , "authToken" > | An object containing parameters for the TestNetDispenserApiClient class. |
Returns
An instance of the TestNetDispenserApiClient class.
Example
const client = clientManager.getTestNetDispenserFromEnvironment({ requestTimeout: 15,});
Defined in
src/types/client-manager.ts:234
getTypedAppClientByCreatorAndName
▸ getTypedAppClientByCreatorAndName<TClient
>(typedClient
, params
): Promise
<InstanceType
<TClient
>>
Returns a new typed client, resolving the app by creator address and name.
Type parameters
Name | Type |
---|---|
TClient | extends TypedAppClient <InstanceType <TClient >> |
Parameters
Name | Type | Description |
---|---|---|
typedClient | TClient | The typed client type to use |
params | Object | The params to resolve the app by creator address and name |
params.appLookupCache? | AppLookup | An optional cached app lookup that matches a name to on-chain details; either this is needed or indexer is required to be passed in to this ClientManager on construction. |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name |
params.approvalSourceMap? | ProgramSourceMap | Optional source map for the approval program |
params.clearSourceMap? | ProgramSourceMap | Optional source map for the clear state program |
params.creatorAddress | string | Address | The address of the creator account for the app |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
params.ignoreCache? | boolean | Whether or not to ignore the AppDeployer lookup cache and force an on-chain lookup, default: use any cached value |
Returns
Promise
<InstanceType
<TClient
>>
The typed client instance
Example
const appClient = clientManager.getTypedAppClientByCreatorAndName(MyContractClient, { creatorAddress: 'CREATORADDRESS', defaultSender: alice,});
Example
const appClient = clientManager.getTypedAppClientByCreatorAndName(MyContractClient, { creatorAddress: 'CREATORADDRESS', name: 'contract-name', defaultSender: alice,});
Defined in
src/types/client-manager.ts:358
getTypedAppClientById
▸ getTypedAppClientById<TClient
>(typedClient
, params
): InstanceType
<TClient
>
Returns a new typed client, resolving the app by app ID.
Type parameters
Name | Type |
---|---|
TClient | extends TypedAppClient <InstanceType <TClient >> |
Parameters
Name | Type | Description |
---|---|---|
typedClient | TClient | The typed client type to use |
params | Object | The params to resolve the app by ID |
params.appId | bigint | The ID of the app instance this client should make calls against. |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name |
params.approvalSourceMap? | ProgramSourceMap | Optional source map for the approval program |
params.clearSourceMap? | ProgramSourceMap | Optional source map for the clear state program |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
Returns
InstanceType
<TClient
>
The typed client instance
Example
const appClient = clientManager.getTypedAppClientById(MyContractClient, { appId: 12345n, defaultSender: alice,});
Defined in
src/types/client-manager.ts:382
getTypedAppClientByNetwork
▸ getTypedAppClientByNetwork<TClient
>(typedClient
, params?
): Promise
<InstanceType
<TClient
>>
Returns a new typed client, resolves the app ID for the current network based on pre-determined network-specific app IDs specified in the ARC-56 app spec.
If no IDs are in the app spec or the network isn’t recognised, an error is thrown.
Type parameters
Name | Type |
---|---|
TClient | extends TypedAppClient <InstanceType <TClient >> |
Parameters
Name | Type | Description |
---|---|---|
typedClient | TClient | The typed client type to use |
params? | Object | The params to resolve the app by network |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name |
params.approvalSourceMap? | ProgramSourceMap | Optional source map for the approval program |
params.clearSourceMap? | ProgramSourceMap | Optional source map for the clear state program |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
Returns
Promise
<InstanceType
<TClient
>>
The typed client instance
Example
const appClient = clientManager.getTypedAppClientByNetwork(MyContractClient, { defaultSender: alice,});
Defined in
src/types/client-manager.ts:408
getTypedAppFactory
▸ getTypedAppFactory<TClient
>(typedFactory
, params?
): TClient
Returns a new typed app factory.
Type parameters
Name |
---|
TClient |
Parameters
Name | Type | Description |
---|---|---|
typedFactory | TypedAppFactory <TClient > | The typed factory type to use |
params? | Object | The params to resolve the factory by |
params.appName? | string | Optional override for the app name; used for on-chain metadata and lookups. Defaults to the ARC-32/ARC-56 app spec name. |
params.defaultSender? | string | Address | Optional address to use for the account to use as the default sender for calls. |
params.defaultSigner? | TransactionSigner | Optional signer to use as the default signer for default sender calls (if not specified then the signer will be resolved from AlgorandClient ). |
params.deletable? | boolean | Whether or not the contract should have deploy-time permanence control set, undefined = ignore. If specified here will get used in calls to deploy and create calls unless overridden in those calls. Useful if you want to vend multiple contracts from the same factory without specifying this value for each call. |
params.deployTimeParams? | TealTemplateParams | Optional deploy-time TEAL template replacement parameters. If specified here will get used in calls to deploy and create calls unless overridden in those calls. Useful if you want to vend multiple contracts from the same factory without specifying this value for each call. |
params.updatable? | boolean | Whether or not the contract should have deploy-time immutability control set, undefined = ignore. If specified here will get used in calls to deploy and create calls unless overridden in those calls. Useful if you want to vend multiple contracts from the same factory without specifying this value for each call. |
params.version? | string | The version of app that is / will be deployed; defaults to 1.0 |
Returns
TClient
The typed client instance
Example
const appFactory = clientManager.getTypedAppFactory(MyContractClient, { sender: alice,});
Defined in
src/types/client-manager.ts:431
isLocalNet
▸ isLocalNet(): Promise
<boolean
>
Returns true if the current network is LocalNet.
Returns
Promise
<boolean
>
True if the current network is LocalNet.
Example
const isLocalNet = await clientManager.isLocalNet();
Defined in
src/types/client-manager.ts:171
isMainNet
▸ isMainNet(): Promise
<boolean
>
Returns true if the current network is MainNet.
Returns
Promise
<boolean
>
True if the current network is MainNet.
Example
const isMainNet = await clientManager.isMainNet();
Defined in
src/types/client-manager.ts:195
isTestNet
▸ isTestNet(): Promise
<boolean
>
Returns true if the current network is TestNet.
Returns
Promise
<boolean
>
True if the current network is TestNet.
Example
const isTestNet = await clientManager.isTestNet();
Defined in
src/types/client-manager.ts:183
network
▸ network(): Promise
<NetworkDetails
>
Get details about the current network.
Returns
Promise
<NetworkDetails
>
The current network details
Example
const network = await networkClient.network();const genesisId = network.genesisId;
Defined in
src/types/client-manager.ts:135
genesisIdIsLocalNet
▸ genesisIdIsLocalNet(genesisId
): boolean
Returns true if the given network genesisId is associated with a LocalNet network.
Parameters
Name | Type | Description |
---|---|---|
genesisId | string | The network genesis ID |
Returns
boolean
Whether the given genesis ID is associated with a LocalNet network
Example
const isLocalNet = ClientManager.genesisIdIsLocalNet('testnet-v1.0');
Defined in
src/types/client-manager.ts:159
getAlgoNodeConfig
▸ getAlgoNodeConfig(network
, config
): AlgoClientConfig
Returns the Algorand configuration to point to the free tier of the AlgoNode service.
Parameters
Name | Type | Description |
---|---|---|
network | "testnet" | "mainnet" | Which network to connect to - TestNet or MainNet |
config | "algod" | "indexer" | Which algod config to return - Algod or Indexer |
Returns
The AlgoNode client configuration
Example
const config = ClientManager.getAlgoNodeConfig('testnet', 'algod');
Defined in
src/types/client-manager.ts:545
getAlgodClient
▸ getAlgodClient(config
): AlgodClient
Returns an algod SDK client that automatically retries on idempotent calls.
Parameters
Name | Type | Description |
---|---|---|
config | AlgoClientConfig | The config of the client |
Returns
AlgodClient
The Algod client
Example
const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('testnet', 'algod'));await algod.healthCheck().do();
Example
const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('mainnet', 'algod'));await algod.healthCheck().do();
Example
const algod = ClientManager.getAlgodClient({ server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',});await algod.healthCheck().do();
Defined in
src/types/client-manager.ts:590
getAlgodClientFromEnvironment
▸ getAlgodClientFromEnvironment(): AlgodClient
Returns an algod SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
Returns
AlgodClient
The Algod client
Example
// Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKENconst algod = ClientManager.getAlgodClientFromEnvironment();await algod.healthCheck().do();
Defined in
src/types/client-manager.ts:608
getAlgodConfigFromEnvironment
▸ getAlgodConfigFromEnvironment(): AlgoClientConfig
Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment)
Expects process.env.ALGOD_SERVER
to be defined, and you can also specify process.env.ALGOD_PORT
and process.env.ALGOD_TOKEN
.
Returns
The Algod client configuration
Throws
Error if process.env.ALGOD_SERVER
is not defined
Example
const config = ClientManager.getAlgodConfigFromEnvironment();
Defined in
src/types/client-manager.ts:492
getConfigFromEnvironmentOrLocalNet
▸ getConfigFromEnvironmentOrLocalNet(): AlgoConfig
Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)
If both process.env.INDEXER_SERVER
and process.env.ALGOD_SERVER
is defined it will use both along with optional process.env.ALGOD_PORT
, process.env.ALGOD_TOKEN
, process.env.INDEXER_PORT
and process.env.INDEXER_TOKEN
.
If only process.env.ALGOD_SERVER
is defined it will use this along with optional process.env.ALGOD_PORT
and process.env.ALGOD_TOKEN
and leave indexer as undefined
.
If only process.env.INDEXER_SERVER
is defined it will use the default (LocalNet) configuration for both algod and indexer.
It will return a KMD configuration that uses process.env.KMD_PORT
(or port 4002) if process.env.ALGOD_SERVER
is defined,
otherwise it will use the default LocalNet config unless it detects testnet or mainnet.
Returns
The config for algod, indexer and kmd
Example
const config = ClientManager.getConfigFromEnvironmentOrLocalNet();
Defined in
src/types/client-manager.ts:456
getDefaultLocalNetConfig
▸ getDefaultLocalNetConfig(configOrPort
): AlgoClientConfig
Returns the Algorand configuration to point to the default LocalNet.
Parameters
Name | Type | Description |
---|---|---|
configOrPort | number | "algod" | "indexer" | "kmd" | Which algod config to return - algod, kmd, or indexer OR a port number |
Returns
The LocalNet client configuration
Example
const config = ClientManager.getDefaultLocalNetConfig('algod');
Defined in
src/types/client-manager.ts:561
getIndexerClient
▸ getIndexerClient(config
): IndexerClient
Returns an indexer SDK client that automatically retries on idempotent calls
Parameters
Name | Type | Description |
---|---|---|
config | AlgoClientConfig | The config of the client |
Returns
IndexerClient
The Indexer client
Example
const indexer = ClientManager.getIndexerClient( ClientManager.getAlgoNodeConfig('testnet', 'indexer'),);await indexer.makeHealthCheck().do();
Example
const indexer = ClientManager.getIndexerClient( ClientManager.getAlgoNodeConfig('mainnet', 'indexer'),);await indexer.makeHealthCheck().do();
Example
const indexer = ClientManager.getIndexerClient({ server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',});await indexer.makeHealthCheck().do();
Defined in
src/types/client-manager.ts:633
getIndexerClientFromEnvironment
▸ getIndexerClientFromEnvironment(): IndexerClient
Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
Returns
IndexerClient
The Indexer client
Example
// Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKENconst indexer = ClientManager.getIndexerClientFromEnvironment();await indexer.makeHealthCheck().do();
Defined in
src/types/client-manager.ts:652
getIndexerConfigFromEnvironment
▸ getIndexerConfigFromEnvironment(): AlgoClientConfig
Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment).
Expects process.env.INDEXER_SERVER
to be defined, and you can also specify process.env.INDEXER_PORT
and process.env.INDEXER_TOKEN
.
Returns
The Indexer client configuration
Throws
Error if process.env.INDEXER_SERVER
is not defined
Example
const config = ClientManager.getIndexerConfigFromEnvironment();
Defined in
src/types/client-manager.ts:519
getKmdClient
▸ getKmdClient(config
): KmdClient
Returns a KMD SDK client.
KMD client allows you to export private keys, which is useful to (for instance) get the default account in a LocalNet network.
Parameters
Name | Type | Description |
---|---|---|
config | AlgoClientConfig | The config for the client |
Returns
KmdClient
The KMD client
Example
const kmd = ClientManager.getKmdClient({ server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',});
Defined in
src/types/client-manager.ts:668
getKmdClientFromEnvironment
▸ getKmdClientFromEnvironment(): KmdClient
Returns a KMD SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).
Returns
KmdClient
The KMD client
Example
// Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKENconst kmd = ClientManager.getKmdClientFromEnvironment();