pyteal icon indicating copy to clipboard operation
pyteal copied to clipboard

PyTeal Examples - Asset.py and Security_Token.py

Open duuren opened this issue 3 years ago • 1 comments

Subject of the issue

These two PyTeal examples apply the command LocalPut in "on_creation" as part of the function "approval_program". This will result in an error as the account of the creator is not automatically opted in to the smart contract which is required to define local keys / values.

Your environment

Steps to reproduce

  1. run the programme

Expected behaviour

Actual behaviour

duuren avatar Jan 11 '22 20:01 duuren

If this bug is acknowledged, i can submit a pull request. It can be solved by amending 'register' clause:

register = Seq( [ App.localPut(Int(0), Bytes("balance"), Int(0)), If ( Global.creator_address() == Txn.sender(), Seq( [
App.localPut(Int(0), Bytes("contract admin"), Int(1)), App.localPut(Int(0), Bytes("transfer admin"), Int(1)), Return(Int(1)), ] ),
Return(Int(1)) ),

    ]
)

duuren avatar Jan 12 '22 20:01 duuren

Thanks for taking a close look at the examples! I believe you can create with oncomplete set to OptIn, which would allow a creation like this to work.

algoanne avatar Sep 16 '22 15:09 algoanne