I’m running the counter applications in the docs, and I made a small change: I’d like to check that the count value exists in state.
Because count is initialized to 0, I figured I could call global get ex with the current application ID and use the Maybe Value to do the check. However, I get the following error:
File "/usr/local/lib/python3.9/site-packages/pyteal/compiler/compiler.py", line 215, in compileTeal
localSlotAssignments = assignScratchSlotsToSubroutines(
File "/usr/local/lib/python3.9/site-packages/pyteal/compiler/scratchslots.py", line 95, in assignScratchSlotsToSubroutines
raise TealInternalError(msg) from errors[0]
pyteal.TealInternalError: Encountered 1 error when assigning slots to subroutine
Here is the code: The only change between this and the counter (add, deduct) example in the official algorand docs is the first line , and the third line in the And block.
myStatus = App.globalGetEx(Txn.applications[0], Bytes("Count")).hasValue()
handle_noop = Cond(
[And(
Global.group_size() == Int(1),
Txn.application_args[0] == Bytes("Add"),
myStatus > Int(0)
),add],
[And(
Global.group_size() == Int(1),
Txn.application_args[0] == Bytes("Deduct"),
), deduct]
)