Decorator Parameters
Beaker Application decorators accept parameters that apply configurations to the methods they decorate.
Read Only
Methods that are meant to only produce information, having no side effects, should be flagged as read only.
See ARC22 for more details.
class ROAppState:
count = ApplicationStateValue(stack_type=TealType.uint64)
app = Application("CoolApp", state=ROAppState())
@app.external(read_only=True)
def get_count(id_of_thing: abi.Uint8, *, output: abi.Uint64):
return output.set(app.state.count)
On Complete
If a method expects the ApplicationCallTransaction
to have a certain OnComplete
other than NoOp
, one of the other OnComplete
decorators may be used instead of external
with a method config set.
- class beaker.application.Application[source]
- external(fn: Callable[[...], Expr], /) ABIReturnSubroutine [source]
- external(*, method_config: pyteal.MethodConfig | dict[Literal['no_op', 'opt_in', 'close_out', 'update_application', 'delete_application'], 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', 'update_application', 'delete_application'], 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', 'update_application', 'delete_application'], 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', 'update_application', 'delete_application'], 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 – <TODO>
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
The ARC4 spec allows applications to define externals for bare
methods, that is, methods with no application arguments.
Routing for bare
methods is based on the transaction’s OnComplete
and whether or not it’s a create transaction, not based on the method selector as non-bare methods.
The same handlers described above will also work for bare
method calls but multiple OnComplete
values can be handled with the bare_external
decorator.
Multiple Bare externals
If a method requires handling multiple OnComplete
actions, use Application.external
with the parameter bare=True