PyTeal Examples - Asset.py and Security_Token.py
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
- run the programme
Expected behaviour
Actual behaviour
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))
),
]
)
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.