Application

This is the class that should be initialized for all Beaker Applications.

class beaker.Application[source]

A class representing an Application.

__init__(name: str, *, descr: str | None = None, build_options: beaker.build_options.BuildOptions | None = None)[source]
__init__(name: str, *, state: TState, descr: str | None = None, build_options: beaker.build_options.BuildOptions | None = None)
apply(func: ~collections.abc.Callable[[~typing.Concatenate[~beaker.application.Application[~beaker.application.TState], ~P]], ~beaker.application.T], *args: ~typing.~P, **kwargs: ~typing.~P) Application[TState][source]

Apply a blueprint function to the application

Parameters

func – the blueprint function to apply to the application

build(client: AlgodClient | None = None) ApplicationSpecification[source]

Build the application specification, including transpiling the application to TEAL, and fully compiling any nested (i.e. precompiled) apps/lsigs to byte code.

Note: .

Parameters
  • client (optional) – An Algod client that is required if there are any precompiled so they can be fully

  • compiled.

clear_state(fn: Callable[[], Expr], /) SubroutineFnWrapper[source]
clear_state(*, name: str | None = None, override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]

Mark a method as one that should be callable during application clear-state.

Parameters
  • name – The name of the method. If not provided, the name of the method will be used.

  • override – If True, the method will override any existing method with the same name.

close_out(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
close_out(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
close_out(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
close_out(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
close_out(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Mark a method as one that should be callable during application close-out.

Parameters
  • name – The name of the method. If not provided, the name of the method will be used.

  • authorize – A function that will be called to authorize the method. If not provided, the method will not be authorized.

  • bare – If True, the router will only consider the OnComplete of the app call transaction to do routing.

  • override – If True, the method will override any existing method with the same name.

create(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
create(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
create(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
create(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
create(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Mark a method as one that should be callable during application create.

delete(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
delete(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
delete(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
delete(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
delete(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Mark a method as one that should be callable during application delete.

Parameters
  • name – The name of the method. If not provided, the name of the method will be used.

  • authorize – A function that will be called to authorize the method. If not provided, the method will not be authorized.

  • bare – If True, the router will only consider the OnComplete of the app call transaction to do routing.

  • override – If True, the method will override any existing method with the same name.

external(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
external(*, method_config: pyteal.MethodConfig | dict[Literal['no_op', 'opt_in', 'close_out', 'clear_state', 'update_application', 'delete_application'], algokit_utils.application_specification.CallConfig | pyteal.CallConfig] | None = None, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, read_only: bool = False, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
external(*, method_config: pyteal.MethodConfig | dict[Literal['no_op', 'opt_in', 'close_out', 'clear_state', 'update_application', 'delete_application'], algokit_utils.application_specification.CallConfig | pyteal.CallConfig] | None = None, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], read_only: bool = False, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
external(*, method_config: pyteal.MethodConfig | dict[Literal['no_op', 'opt_in', 'close_out', 'clear_state', 'update_application', 'delete_application'], algokit_utils.application_specification.CallConfig | pyteal.CallConfig], name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
external(*, method_config: pyteal.MethodConfig | dict[Literal['no_op', 'opt_in', 'close_out', 'clear_state', 'update_application', 'delete_application'], algokit_utils.application_specification.CallConfig | pyteal.CallConfig] | None = None, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool, read_only: bool = False, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Add the method decorated to be handled as an ABI method for the Application

Parameters
  • fn – The function being wrapped.

  • method_config – A MethodConfig or MethodConfigDict that defines the OnComplete fields that are valid for this method

  • name – Name of ABI method. If not set, name of the python method will be used. Useful for method overriding.

  • authorize – a subroutine with input of Txn.sender() and output uint64 interpreted as allowed if the output>0.

  • bare

  • read_only – Mark a method as callable with no fee using dryrun or simulate

  • override

Returns

An ABIReturnSubroutine or SubroutineFnWrapper

initialize_global_state() Expr[source]

Initialize any global state variables declared

Returns

The Expr to initialize the application state.

Return type

pyteal.Expr

initialize_local_state(addr: pyteal.Expr | None = None) Expr[source]

Initialize any local state variables declared

Parameters

addr – Optional, address of account to initialize state for (defaults to Txn.sender()).

Returns

The Expr to initialize the account state.

Return type

pyteal.Expr

no_op(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
no_op(*, allow_call: bool = True, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, read_only: bool = False, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
no_op(*, allow_call: bool = True, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], read_only: bool = False, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
no_op(*, allow_call: bool = True, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
no_op(*, allow_call: bool = True, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool, read_only: bool = False, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Mark a method as one that should be callable during application no-op.

Parameters
  • allow_call – If True, the method will be callable during application no-op after creation.

  • allow_create – If True, the method will be callable during application create.

  • name – The name of the method. If not provided, the name of the method will be used.

  • authorize – A function that will be called to authorize the method. If not provided, the method will not be authorized.

  • bare – If True, the router will only consider the OnComplete of the app call transaction to do routing.

  • override – If True, the method will override any existing method with the same name.

opt_in(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
opt_in(*, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
opt_in(*, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
opt_in(*, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
opt_in(*, allow_create: bool = False, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool = False, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Mark a method as one that should be callable during application opt-in.

Parameters
  • allow_create – If True, the method will be callable even if the application does not exist.

  • name – The name of the method. If not provided, the name of the method will be used.

  • authorize – A function that will be called to authorize the method. If not provided, the method will not be authorized.

  • bare – If True, the router will only consider the OnComplete of the app call transaction to do routing.

  • override – If True, the method will override any existing method with the same name.

precompiled(value: Application, /) PrecompiledApplication[source]
precompiled(value: LogicSignature, /) PrecompiledLogicSignature
precompiled(value: LogicSignatureTemplate, /) PrecompiledLogicSignatureTemplate

Precompile an Application or LogicSignature for use in the logic of the application.

update(fn: Callable[[...], Expr], /) ABIReturnSubroutine[source]
update(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
update(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[False], override: bool | None = False) Callable[[Callable[[...], Expr]], ABIReturnSubroutine]
update(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: Literal[True], override: bool | None = False) Callable[[Callable[[], Expr]], SubroutineFnWrapper]
update(*, name: str | None = None, authorize: collections.abc.Callable[[pyteal.Expr], pyteal.Expr] | pyteal.SubroutineFnWrapper | None = None, bare: bool, override: bool | None = False) collections.abc.Callable[[collections.abc.Callable[[...], pyteal.Expr]], pyteal.ABIReturnSubroutine] | collections.abc.Callable[[collections.abc.Callable[[], pyteal.Expr]], pyteal.SubroutineFnWrapper]

Mark a method as one that should be callable during application update.

Parameters
  • name – The name of the method. If not provided, the name of the method will be used.

  • authorize – A function that will be called to authorize the method. If not provided, the method will not be authorized.

  • bare – If True, the router will only consider the OnComplete of the app call transaction to do routing.

  • override – If True, the method will override any existing method with the same name.