PyTEAL: Loop load from scratch slots - Algorand

PyTEAL: Loop load from scratch slots

post by hernandp on Oct 22, 2021

I’m finding problems in pyTEAL looping over scratch slots if ScratchVar(type, i) accepts int as a slot-id type but not Int. Is this possible?

# Clear slots loop

For(i.store(Int(0)), i.load() < num_slots, i.store(i.load() + Int(1))).Do(
            Seq([\
                (ScratchVar(TealType.uint64, i.load())).store(Int(0))\
            ]))

In pseudo this should conform to

FOR I = 0 TO NUM_SLOTS DO
       STORE 0 -> SLOT(I)
NEXT

This is solvable in current version?

At least is perfectly possible in TEAL5 by using looping and stores opcode.

Kind regards,

post by fabrice on Oct 22, 2021

It looks like PyTEAL does not support this yet.

That’s a very good point.

Can you open an issue on GitHub - algorand/pyteal: Algorand Smart Contracts in Python and cross-reference it with this post?

post by hernandp on Oct 22, 2021

I will do. Thank you and have a nice weekend.

post by fabrice on Oct 25, 2021

Reply