algokit_utils.algorand ====================== .. py:module:: algokit_utils.algorand Classes ------- .. autoapisummary:: algokit_utils.algorand.AlgorandClient Module Contents --------------- .. py:class:: AlgorandClient(config: algokit_utils.models.network.AlgoClientConfigs | algokit_utils.clients.client_manager.AlgoSdkClients) A client that brokers easy access to Algorand functionality. .. py:method:: set_default_validity_window(validity_window: int) -> typing_extensions.Self Sets the default validity window for transactions. :param validity_window: The number of rounds between the first and last valid rounds :return: The `AlgorandClient` so method calls can be chained :example: >>> algorand = AlgorandClient.mainnet().set_default_validity_window(1000); .. py:method:: 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. :param signer: The signer to use, either a `TransactionSigner` or a `TransactionSignerAccountProtocol` :return: The `AlgorandClient` so method calls can be chained :example: >>> signer = SigningAccount(private_key=..., address=...) >>> algorand = AlgorandClient.mainnet().set_default_signer(signer) .. py:method:: set_signer(sender: str, signer: algosdk.atomic_transaction_composer.TransactionSigner) -> typing_extensions.Self Tracks the given account for later signing. :param sender: The sender address to use this signer for :param signer: The signer to sign transactions with for the given sender :return: The `AlgorandClient` so method calls can be chained :example: >>> signer = SigningAccount(private_key=..., address=...) >>> algorand = AlgorandClient.mainnet().set_signer(signer.addr, signer.signer) .. py:method:: 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. :param signer: The signer to use, either a `TransactionSigner` or a `TransactionSignerAccountProtocol` :return: The `AlgorandClient` so method calls can be chained :example: >>> 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) .. py:method:: 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. :param suggested_params: The suggested params to use :param until: A timestamp until which to cache, or if not specified then the timeout is used :return: The `AlgorandClient` so method calls can be chained :example: >>> algorand = AlgorandClient.mainnet().set_suggested_params_cache(suggested_params, time.time() + 3.6e6) .. py:method:: set_suggested_params_cache_timeout(timeout: int) -> typing_extensions.Self Sets the timeout for caching suggested params. :param timeout: The timeout in milliseconds :return: The `AlgorandClient` so method calls can be chained :example: >>> algorand = AlgorandClient.mainnet().set_suggested_params_cache_timeout(10_000) .. py:method:: get_suggested_params() -> algosdk.transaction.SuggestedParams Get suggested params for a transaction (either cached or from algod if the cache is stale or empty) :example: >>> algorand = AlgorandClient.mainnet().get_suggested_params() .. py:method:: new_group() -> algokit_utils.transactions.transaction_composer.TransactionComposer Start a new `TransactionComposer` transaction group :example: >>> composer = AlgorandClient.mainnet().new_group() >>> result = await composer.add_transaction(payment).send() .. py:property:: client :type: algokit_utils.clients.client_manager.ClientManager Get clients, including algosdk clients and app clients. :example: >>> clientManager = AlgorandClient.mainnet().client .. py:property:: account :type: algokit_utils.accounts.account_manager.AccountManager Get or create accounts that can sign transactions. :example: >>> accountManager = AlgorandClient.mainnet().account .. py:property:: asset :type: algokit_utils.assets.asset_manager.AssetManager Get or create assets. :example: >>> assetManager = AlgorandClient.mainnet().asset .. py:property:: app :type: algokit_utils.applications.app_manager.AppManager Get or create applications. :example: >>> appManager = AlgorandClient.mainnet().app .. py:property:: app_deployer :type: algokit_utils.applications.app_deployer.AppDeployer Get or create applications. :example: >>> appDeployer = AlgorandClient.mainnet().app_deployer .. py:property:: send :type: algokit_utils.transactions.transaction_sender.AlgorandClientTransactionSender Methods for sending a transaction and waiting for confirmation :example: >>> result = await AlgorandClient.mainnet().send.payment( >>> PaymentParams( >>> sender="SENDERADDRESS", >>> receiver="RECEIVERADDRESS", >>> amount=AlgoAmount(algo-1) >>> )) .. py:property:: create_transaction :type: algokit_utils.transactions.transaction_creator.AlgorandClientTransactionCreator Methods for building transactions :example: >>> transaction = AlgorandClient.mainnet().create_transaction.payment( >>> PaymentParams( >>> sender="SENDERADDRESS", >>> receiver="RECEIVERADDRESS", >>> amount=AlgoAmount(algo=1) >>> )) .. py:method:: default_localnet() -> AlgorandClient :staticmethod: Returns an `AlgorandClient` pointing at default LocalNet ports and API token. :return: The `AlgorandClient` :example: >>> algorand = AlgorandClient.default_localnet() .. py:method:: testnet() -> AlgorandClient :staticmethod: Returns an `AlgorandClient` pointing at TestNet using AlgoNode. :return: The `AlgorandClient` :example: >>> algorand = AlgorandClient.testnet() .. py:method:: mainnet() -> AlgorandClient :staticmethod: Returns an `AlgorandClient` pointing at MainNet using AlgoNode. :return: The `AlgorandClient` :example: >>> algorand = AlgorandClient.mainnet() .. py:method:: from_clients(algod: algosdk.v2client.algod.AlgodClient, indexer: algosdk.v2client.indexer.IndexerClient | None = None, kmd: algosdk.kmd.KMDClient | None = None) -> AlgorandClient :staticmethod: Returns an `AlgorandClient` pointing to the given client(s). :param algod: The algod client to use :param indexer: The indexer client to use :param kmd: The kmd client to use :return: The `AlgorandClient` :example: >>> algorand = AlgorandClient.from_clients(algod, indexer, kmd) .. py:method:: from_environment() -> AlgorandClient :staticmethod: 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. :return: The `AlgorandClient` :example: >>> algorand = AlgorandClient.from_environment() .. py:method:: 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 :staticmethod: Returns an `AlgorandClient` from the given config. :param algod_config: The config to use for the algod client :param indexer_config: The config to use for the indexer client :param kmd_config: The config to use for the kmd client :return: The `AlgorandClient` :example: >>> algorand = AlgorandClient.from_config(algod_config, indexer_config, kmd_config)