Client Management
Client management is one of the core capabilities provided by AlgoKit Utils. It allows you to create algod, indexer and kmd clients against various networks resolved from environment or specified configuration.
Any AlgoKit Utils function that needs one of these clients will take the underlying algosdk
classes:
algosdk.v2client.algod.AlgodClient
algosdk.v2client.indexer.IndexerClient
algosdk.kmd.KMDClient
Network Configuration
The network configuration is specified using the AlgoClientConfig
class. This same interface is used to specify the config for algod, indexer and kmd clients.
There are a number of ways to produce one of these configuration objects:
- Manually creating the object, e.g.
AlgoClientConfig(server="https://myalgodnode.com", token="SECRET_TOKEN")
algokit_utils.get_algonode_config(network, config, token)
: Loads an Algod or indexer config against Nodely to either MainNet or TestNetalgokit_utils.get_default_localnet_config(configOrPort)
: Loads an Algod, Indexer or Kmd config against LocalNet using the default configuration
See the below usage example for how to get a network configuration:
1# TODO - USAGE EXAMPLE
Clients
Once you have the configuration for a client, to get the client you can use the following functions:
algokit_utils.get_algod_client(config)
: Returns an Algod client for the given configuration, or if none is provided, retrieves a configuration from the environment usingALGOD_SERVER
,ALGOD_TOKEN
and optionallyALGOD_PORT
.algokit_utils.get_indexer_client(config)
: Returns an Indexer client for given configuration, or if none is provided, retrieves a configuration from the environment usingINDEXER_SERVER
,INDEXER_TOKEN
and optionallyINDEXER_PORT
algokit_utils.get_kmd_client_from_algod_client(config)
: - Returns a Kmd client based on the provided algod client configuration, with the assumption the KMD service is running on the same host but a different port (eitherKMD_PORT
environment variable or4002
by default)
Here is an example of how to get all three clients:
1# TODO - USAGE EXAMPLE