algokit_utils.applications.app_factory ====================================== .. py:module:: algokit_utils.applications.app_factory Classes ------- .. autoapisummary:: algokit_utils.applications.app_factory.AppFactoryParams algokit_utils.applications.app_factory.AppFactoryCreateParams algokit_utils.applications.app_factory.AppFactoryCreateMethodCallParams algokit_utils.applications.app_factory.AppFactoryCreateMethodCallResult algokit_utils.applications.app_factory.SendAppFactoryTransactionResult algokit_utils.applications.app_factory.SendAppUpdateFactoryTransactionResult algokit_utils.applications.app_factory.SendAppCreateFactoryTransactionResult algokit_utils.applications.app_factory.AppFactoryDeployResult algokit_utils.applications.app_factory.AppFactory Module Contents --------------- .. py:class:: AppFactoryParams .. py:attribute:: algorand :type: algokit_utils.algorand.AlgorandClient .. py:attribute:: app_spec :type: algokit_utils.applications.app_spec.arc56.Arc56Contract | algokit_utils._legacy_v2.application_specification.ApplicationSpecification | str .. py:attribute:: app_name :type: str | None :value: None .. py:attribute:: default_sender :type: str | None :value: None .. py:attribute:: default_signer :type: algosdk.atomic_transaction_composer.TransactionSigner | None :value: None .. py:attribute:: version :type: str | None :value: None .. py:attribute:: compilation_params :type: algokit_utils.applications.app_client.AppClientCompilationParams | None :value: None .. py:class:: AppFactoryCreateParams Bases: :py:obj:`algokit_utils.applications.app_client.AppClientBareCallCreateParams` Parameters for creating application with bare call. .. py:attribute:: on_complete :type: algokit_utils.applications.app_client.CreateOnComplete | None :value: None Optional on complete action .. py:class:: AppFactoryCreateMethodCallParams Bases: :py:obj:`algokit_utils.applications.app_client.AppClientMethodCallCreateParams` Parameters for creating application with method call .. py:class:: AppFactoryCreateMethodCallResult Bases: :py:obj:`algokit_utils.transactions.transaction_sender.SendSingleTransactionResult`, :py:obj:`Generic`\ [\ :py:obj:`ABIReturnT`\ ] Base class for transaction results. Represents the result of sending a single transaction. .. py:attribute:: app_id :type: int .. py:attribute:: app_address :type: str .. py:attribute:: compiled_approval :type: Any | None :value: None .. py:attribute:: compiled_clear :type: Any | None :value: None .. py:attribute:: abi_return :type: ABIReturnT | None :value: None .. py:class:: SendAppFactoryTransactionResult Bases: :py:obj:`algokit_utils.transactions.transaction_sender.SendAppTransactionResult`\ [\ :py:obj:`algokit_utils.applications.abi.Arc56ReturnValueType`\ ] Result of an application transaction. Contains the ABI return value if applicable. .. py:class:: SendAppUpdateFactoryTransactionResult Bases: :py:obj:`algokit_utils.transactions.transaction_sender.SendAppUpdateTransactionResult`\ [\ :py:obj:`algokit_utils.applications.abi.Arc56ReturnValueType`\ ] Result of updating an application. Contains the compiled approval and clear programs. .. py:class:: SendAppCreateFactoryTransactionResult Bases: :py:obj:`algokit_utils.transactions.transaction_sender.SendAppCreateTransactionResult`\ [\ :py:obj:`algokit_utils.applications.abi.Arc56ReturnValueType`\ ] Result of creating a new application. Contains the app ID and address of the newly created application. .. py:class:: AppFactoryDeployResult Result from deploying an application via AppFactory .. py:attribute:: app :type: algokit_utils.applications.app_deployer.ApplicationMetaData The application metadata .. py:attribute:: operation_performed :type: algokit_utils.applications.app_deployer.OperationPerformed The operation performed .. py:attribute:: create_result :type: SendAppCreateFactoryTransactionResult | None :value: None The create result .. py:attribute:: update_result :type: SendAppUpdateFactoryTransactionResult | None :value: None The update result .. py:attribute:: delete_result :type: SendAppFactoryTransactionResult | None :value: None The delete result .. py:method:: from_deploy_result(response: algokit_utils.applications.app_deployer.AppDeployResult, deploy_params: algokit_utils.applications.app_deployer.AppDeployParams, app_spec: algokit_utils.applications.app_spec.arc56.Arc56Contract, app_compilation_data: algokit_utils.applications.app_client.AppClientCompilationResult | None = None) -> typing_extensions.Self :classmethod: Construct an AppFactoryDeployResult from a deployment result. :param response: The deployment response. :param deploy_params: The deployment parameters. :param app_spec: The application specification. :param app_compilation_data: Optional app compilation data. :return: An instance of AppFactoryDeployResult. .. py:class:: AppFactory(params: AppFactoryParams) ARC-56/ARC-32 app factory that, for a given app spec, allows you to create and deploy one or more app instances and to create one or more app clients to interact with those (or other) app instances. :param params: The parameters for the factory :example: >>> factory = AppFactory(AppFactoryParams( >>> algorand=AlgorandClient.mainnet(), >>> app_spec=app_spec, >>> ) >>> ) .. py:property:: app_name :type: str The name of the app .. py:property:: app_spec :type: algokit_utils.applications.app_spec.arc56.Arc56Contract The app spec .. py:property:: algorand :type: algokit_utils.algorand.AlgorandClient The algorand client .. py:property:: params :type: _MethodParamsBuilder Get parameters to create transactions (create and deploy related calls) for the current app. A good mental model for this is that these parameters represent a deferred transaction creation. :example: Create a transaction in the future using Algorand Client >>> create_app_params = app_factory.params.create( ... AppFactoryCreateMethodCallParams( ... method='create_method', ... args=[123, 'hello'] ... ) ... ) >>> # ... >>> algorand.send.app_create_method_call(create_app_params) :example: Define a nested transaction as an ABI argument >>> create_app_params = appFactory.params.create( ... AppFactoryCreateMethodCallParams( ... method='create_method', ... args=[123, 'hello'] ... ) ... ) >>> app_client.send.call( ... AppClientMethodCallParams( ... method='my_method', ... args=[create_app_params] ... ) ... ) .. py:property:: send :type: _TransactionSender Get the transaction sender. :return: The _TransactionSender instance. .. py:property:: create_transaction :type: _TransactionCreator Get the transaction creator. :return: The _TransactionCreator instance. .. py:method:: deploy(*, on_update: algokit_utils.applications.app_deployer.OnUpdate | None = None, on_schema_break: algokit_utils.applications.app_deployer.OnSchemaBreak | None = None, create_params: algokit_utils.applications.app_client.AppClientMethodCallCreateParams | algokit_utils.applications.app_client.AppClientBareCallCreateParams | None = None, update_params: algokit_utils.applications.app_client.AppClientMethodCallParams | algokit_utils.applications.app_client.AppClientBareCallParams | None = None, delete_params: algokit_utils.applications.app_client.AppClientMethodCallParams | algokit_utils.applications.app_client.AppClientBareCallParams | None = None, existing_deployments: algokit_utils.applications.app_deployer.ApplicationLookup | None = None, ignore_cache: bool = False, app_name: str | None = None, send_params: algokit_utils.models.transaction.SendParams | None = None, compilation_params: algokit_utils.applications.app_client.AppClientCompilationParams | None = None) -> tuple[algokit_utils.applications.app_client.AppClient, AppFactoryDeployResult] Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified). **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`. **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. :param on_update: The action to take if there is an update to the app :param on_schema_break: The action to take if there is a breaking state schema change to the app :param create_params: The arguments to create the app :param update_params: The arguments to update the app :param delete_params: The arguments to delete the app :param existing_deployments: The existing deployments to use :param ignore_cache: Whether to ignore the cache :param app_name: The name of the app :param send_params: The parameters for the send call :param compilation_params: The parameters for the compilation :returns: The app client and the result of the deployment :example: >>> app_client, result = factory.deploy({ >>> create_params=AppClientMethodCallCreateParams( >>> sender='SENDER_ADDRESS', >>> approval_program='APPROVAL PROGRAM', >>> clear_state_program='CLEAR PROGRAM', >>> schema={ >>> "global_byte_slices": 0, >>> "global_ints": 0, >>> "local_byte_slices": 0, >>> "local_ints": 0 >>> } >>> ), >>> update_params=AppClientMethodCallParams( >>> sender='SENDER_ADDRESS' >>> ), >>> delete_params=AppClientMethodCallParams( >>> sender='SENDER_ADDRESS' >>> ), >>> compilation_params=AppClientCompilationParams( >>> updatable=False, >>> deletable=False >>> ), >>> app_name='my_app', >>> on_schema_break=OnSchemaBreak.AppendApp, >>> on_update=OnUpdate.AppendApp >>> }) .. py:method:: get_app_client_by_id(app_id: int, app_name: str | None = None, default_sender: str | None = None, default_signer: algosdk.atomic_transaction_composer.TransactionSigner | None = None, approval_source_map: algosdk.source_map.SourceMap | None = None, clear_source_map: algosdk.source_map.SourceMap | None = None) -> algokit_utils.applications.app_client.AppClient Returns a new `AppClient` client for an app instance of the given ID. :param app_id: The id of the app :param app_name: The name of the app :param default_sender: The default sender address :param default_signer: The default signer :param approval_source_map: The approval source map :param clear_source_map: The clear source map :return AppClient: The app client :example: >>> app_client = factory.get_app_client_by_id(app_id=123) .. py:method:: get_app_client_by_creator_and_name(creator_address: str, app_name: str, default_sender: str | None = None, default_signer: algosdk.atomic_transaction_composer.TransactionSigner | None = None, ignore_cache: bool | None = None, app_lookup_cache: algokit_utils.applications.app_deployer.ApplicationLookup | None = None, approval_source_map: algosdk.source_map.SourceMap | None = None, clear_source_map: algosdk.source_map.SourceMap | None = None) -> algokit_utils.applications.app_client.AppClient Returns a new `AppClient` client, resolving the app by creator address and name using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note). :param creator_address: The creator address :param app_name: The name of the app :param default_sender: The default sender address :param default_signer: The default signer :param ignore_cache: Whether to ignore the cache and force a lookup :param app_lookup_cache: Optional cache of existing app deployments to use instead of querying the indexer :param approval_source_map: Optional source map for the approval program :param clear_source_map: Optional source map for the clear state program :return: An AppClient instance configured for the resolved application :example: >>> app_client = factory.get_app_client_by_creator_and_name( ... creator_address='SENDER_ADDRESS', ... app_name='my_app' ... ) .. py:method:: export_source_maps() -> algokit_utils.models.application.AppSourceMaps .. py:method:: import_source_maps(source_maps: algokit_utils.models.application.AppSourceMaps) -> None Import the provided source maps into the factory. :param source_maps: An AppSourceMaps instance containing the approval and clear source maps. .. py:method:: compile(compilation_params: algokit_utils.applications.app_client.AppClientCompilationParams | None = None) -> algokit_utils.applications.app_client.AppClientCompilationResult Compile the app's TEAL code. :param compilation_params: The compilation parameters :return AppClientCompilationResult: The compilation result :example: >>> compilation_result = factory.compile()