AssetParam not working pyteal - General - Algorand
AssetParam not working pyteal
post by ncoin on Apr 21, 2022
I need to run Assert(AssetParam.clawback(assetid) == verifiedaddr), but it’s not working. Why is this?
post by humblefool on Apr 21, 2022
You need to pass assetId in foreign assets and then pass the index of it to AssetParam.
EX:
clawbackExpr = AssetParam.clawback(Int(0)) clawbackAddr = clawbackExpr.value()
make sure the assetId is passed in the foreign assets.
Here is the doc link: clawbackExpr
post by ncoin on Apr 21, 2022
Thanks for your advice, but that’s what I have done so far - could you please explain what the value does and how to use it in an Assert?
post by humblefool on Apr 21, 2022
AssetParam.clawback() will not return the clawback address, instead it returns the MayBeValue expression.
you need to call .value() on the MayBeValue expression to get the exact value.
Here is the documentation for it: MaybeValue
post by ncoin on Apr 21, 2022
When I do Assert(AssetParam.clawback(assetid).value() == verifiedaddr), it throws the error pyteal.TealCompileError: Scratch slot load occurs before store. Thank you for your help so far.
post by humblefool on Apr 21, 2022
assetClawbackExpr = AssetParam.clawback(Int(0))
assetClawbackAddr = Seq([
assetClawbackExpr,
assetClawbackExpr.value()
])
Assert(assetClawbackAddr == verifiedaddr)
post by ncoin on Apr 21, 2022
Thank you so much for saving me hours of debugging!