How to get arguments in Smart Contract using PYTEAL

Hi everybody,
this is my first approach to TEAL and Smart Contracts, that’s why I’m using PYTEAL to generate TEAL file and so I have some questions.

  1. According to pyteal documentation’s examples (here: PyTeal Examples — PyTeal documentation), I’m trying to put my arguments from my python program to my smart contract using this call:
    txn = transaction.ApplicationOptInTxn(sender, params, index, app_args=args)
    Isn’t it correct? How can I pass my args to Smart Contract? And how can I get it inside Smart Contract?

  2. I need to create some asset (linked to an Algorand account) in Smart Contract. Is it possibile? If yes, how can I do it?

Thank you for your help!

  1. To pass arguments, see Using the SDKs - Algorand Developer Portal (this also works with OptIn transactions, but the example is for a call transaction). To read arguments from the smart contract, see e.g., pyteal/vote.py at 3fe0c94203e56d7e67dc44607afa0fa9fb0bbb54 · algorand/pyteal · GitHub
  2. A stateful smart contract / application cannot issue transaction by itself. But a call to an application can be grouped with other transactions, potentially from stateless smart contracts. Using this pattern, you can easily (indirectly) create assets from a stateful smart contract. Note that assets themselves on Algorand do not require smart contracts to be created.
1 Like

6 posts were split to a new topic: Error: invalid ApplicationArgs when using PyTEAL + Python SDK

A post was merged into an existing topic: Error: invalid ApplicationArgs when using PyTEAL + Python SDK