program = Cond( [Txn.application_id() == Int(0), on_deployment], [Txn.on_completion() == OnComplete.UpdateApplication, handle_update], [Txn.on_completion() == OnComplete.DeleteApplication, Return(Int(0))], # block delete [Txn.on_completion() == OnComplete.CloseOut, handle_closeout], [Txn.on_completion() == OnComplete.OptIn, handle_optin], [ Txn.application_args[0] == Bytes("change_permissions_manager"), change_permissions_manager ], [Txn.application_args[0] == Bytes("add_whitelist"), add_whitelist], [Txn.application_args[0] == Bytes("transfer"), transfer_token]) return program if __name__ == "__main__": params = { "PERM_MANAGER": "EDXG4GGBEHFLNX6A7FGT3F6Z3TQGIU6WVVJNOXGYLVNTLWDOCEJJ35LWJY" } # Overwrite params if sys.argv[1] is passed if (len(sys.argv) > 1): params = parseArgs(sys.argv[1], params) print( compileTeal(approval_program(params["PERM_MANAGER"]), Mode.Application, version=2))
asa_opt_in = And( Global.group_size() == Int(1), Txn.group_index() == Int(0), Txn.type_enum() == Int(4), Txn.asset_amount() == Int(0) ) pay_gold = And( Txn.type_enum() == Int(4), Txn.sender() == tmpl_sender, Txn.asset_amount() <= asset_amt ) combine = Or(asa_opt_in, pay_gold) return combine if __name__ == "__main__": #replace these values with your customized values or pass an external parameter scParam = { "TMPL_SENDER": "M7VR2MGHI35EG2NMYOF3X337636PIOFVSP2HNIFUKAG7WW6BDWDCA3E2DA", "ASSET_AMT": Int(1000) } # Overwrite scParam if sys.argv[1] is passed if(len(sys.argv) > 1): scParam = parseArgs(sys.argv[1], scParam) print(compileTeal(gold_asc(scParam["ASSET_AMT"], Addr(scParam["TMPL_SENDER"])), Mode.Signature))