Pyteal - Conditional Sequence Return - Algorand

Pyteal - Conditional Sequence Return

post by summe64 on Aug 20, 2021

I have a sequence, within it there’s a conditional I need to check. I want it to exit the contract if it Return(0) but it just keeps on going to the next sequence.


balance= AssetHolding.balance(Int(0), Tmpl.Int(“ASSET_ID”))
check_user = Seq([\
  balance,\
  Assert(balance.hasValue()),\
  If(balance.value > Int(0), Return(Int(1)), Return(Int(0))\
])
Seq ([\
 If(Txn.accounts[0]==Tmpl.Addr(“Address”), Return(1), check_user),\
  Assert(…), #say, user doesn’t have balance. it shouldn’t reach here and should just throw assert error.\
])

What is wrong here?

post by ipaleka on Aug 21, 2021

That hasValue returns 1 if the value exists, is it possible that value of 0 means the value exists?

What happens if you change that line to:


Assert(balance.hasValue() == Int(1)),

?