algorand | Algorand Developer Portal

algorand

Classes

AlgorandClient A client that brokers easy access to Algorand functionality.

Module Contents

class algokit_utils.algorand.AlgorandClient(config: algokit_utils.models.network.AlgoClientConfigs | algokit_utils.clients.client_manager.AlgoSdkClients)

A client that brokers easy access to Algorand functionality.

set_default_validity_window(validity_window: int) → typing_extensions.Self

Sets the default validity window for transactions.

algorand = AlgorandClient.mainnet().set_default_validity_window(1000);

set_default_signer(signer: algosdk.atomic_transaction_composer.TransactionSigner | algokit_utils.protocols.account.TransactionSignerAccountProtocol) → typing_extensions.Self

Sets the default signer to use if no other signer is specified.

signer = SigningAccount(private_key=..., address=...)

algorand = AlgorandClient.mainnet().set_default_signer(signer)

set_signer(sender: str, signer: algosdk.atomic_transaction_composer.TransactionSigner) → typing_extensions.Self

Tracks the given account for later signing.

signer = SigningAccount(private_key=..., address=...)

algorand = AlgorandClient.mainnet().set_signer(signer.addr, signer.signer)

set_signer_from_account(signer: algokit_utils.protocols.account.TransactionSignerAccountProtocol) → typing_extensions.Self

Sets the default signer to use if no other signer is specified.

accountManager = AlgorandClient.mainnet()

accountManager.set_signer_from_account(TransactionSignerAccount(address=..., signer=...))

accountManager.set_signer_from_account(algosdk.LogicSigAccount(program, args))

accountManager.set_signer_from_account(SigningAccount(private_key=..., address=...))

accountManager.set_signer_from_account(MultisigAccount(metadata, signing_accounts))

accountManager.set_signer_from_account(account)

set_suggested_params_cache(suggested_params: algosdk.transaction.SuggestedParams, until: float | None = None) → typing_extensions.Self

Sets a cache value to use for suggested params.

algorand = AlgorandClient.mainnet().set_suggested_params_cache(suggested_params, time.time() + 3.6e6)

set_suggested_params_cache_timeout(timeout: int) → typing_extensions.Self

Sets the timeout for caching suggested params.

algorand = AlgorandClient.mainnet().set_suggested_params_cache_timeout(10_000)

get_suggested_params() → algosdk.transaction.SuggestedParams

Get suggested params for a transaction (either cached or from algod if the cache is stale or empty)

algorand = AlgorandClient.mainnet().get_suggested_params()

register_error_transformer(transformer: algokit_utils.transactions.transaction_composer.ErrorTransformer) → typing_extensions.Self

Register a function that will be used to transform an error caught when simulating or executing composed transaction groups made from new_group

unregister_error_transformer(transformer: algokit_utils.transactions.transaction_composer.ErrorTransformer) → typing_extensions.Self

Unregister an error transformer function

new_group() → algokit_utils.transactions.transaction_composer.TransactionComposer

Start a new TransactionComposer transaction group

composer = AlgorandClient.mainnet().new_group()

result = await composer.add_transaction(payment).send()

property client : algokit_utils.clients.client_manager.ClientManager

Get clients, including algosdk clients and app clients.

clientManager = AlgorandClient.mainnet().client

property account _: algokit_utils.accounts.account_manager.AccountManager

Get or create accounts that can sign transactions.

accountManager = AlgorandClient.mainnet().account

property asset _: algokit_utils.assets.asset_manager.AssetManager

Get or create assets.

assetManager = AlgorandClient.mainnet().asset

property app _: algokit_utils.applications.app_manager.AppManager

Get or create applications.

appManager = AlgorandClient.mainnet().app

property app*deployer *: algokit_utils.applications.app_deployer.AppDeployer_

Get or create applications.

appDeployer = AlgorandClient.mainnet().app_deployer

property send _: algokit_utils.transactions.transaction_sender.AlgorandClientTransactionSender

Methods for sending a transaction and waiting for confirmation

result = await AlgorandClient.mainnet().send.payment(

PaymentParams(

sender="SENDERADDRESS",

receiver="RECEIVERADDRESS",

amount=AlgoAmount(algo-1)

))

property create*transaction *: algokit_utils.transactions.transaction_creator.AlgorandClientTransactionCreator

Methods for building transactions

transaction = AlgorandClient.mainnet().create_transaction.payment(

PaymentParams(

sender="SENDERADDRESS",

receiver="RECEIVERADDRESS",

amount=AlgoAmount(algo=1)

))

static default_localnet() → AlgorandClient

Returns an AlgorandClient pointing at default LocalNet ports and API token.

algorand = AlgorandClient.default_localnet()

static testnet() → AlgorandClient

Returns an AlgorandClient pointing at TestNet using AlgoNode.

algorand = AlgorandClient.testnet()

static mainnet() → AlgorandClient

Returns an AlgorandClient pointing at MainNet using AlgoNode.

algorand = AlgorandClient.mainnet()

static from_clients(algod: algosdk.v2client.algod.AlgodClient, indexer: algosdk.v2client.indexer.IndexerClient | None = None, kmd: algosdk.kmd.KMDClient | None = None) → AlgorandClient

Returns an AlgorandClient pointing to the given client(s).

algorand = AlgorandClient.from_clients(algod, indexer, kmd)

static from_environment() → AlgorandClient

Returns an AlgorandClient loading the configuration from environment variables. Retrieve configurations from environment variables when defined or get defaults. Expects to be called from a Python environment.

algorand = AlgorandClient.from_environment()

static from_config(algod_config: algokit_utils.models.network.AlgoClientNetworkConfig, indexer_config: algokit_utils.models.network.AlgoClientNetworkConfig | None = None, kmd_config: algokit_utils.models.network.AlgoClientNetworkConfig | None = None) → AlgorandClient

Returns an AlgorandClient from the given config.

algorand = AlgorandClient.from_config(algod_config, indexer_config, kmd_config)