TEAL Signature mode: dynamic parameters

Hi there,
in the following example:

i see there is a ‘receiver’ parameter given to the function, but this value is actually hard-coded in this specific template. I was wondering if there is a way to pass one (or more) arguments to the function using the Java SDK. In my specific case, i need to create a LogicSig in a dynamic way (receiver and other values change each time), so having the possibility to do it from within my application would be great!
So what i need is:

  1. compile PyTeal to TEAL (generic signature smart contract)
  2. open the TEAL file in my Java application, and create the LogicSig with given parameters (receiver, amount etc.)

The issue with that approach is parameters to a stateless contract are not covered under the signature, so you have to be very careful how you use parameters in the logic. For example if you make receiver a parameter that signed logic sig could be used by anyone to change the receiver without having to get a new signature. You can pass parameters to the contract like you are wanting to do, but you must be very careful. Instead of doing that why not just put placeholders in the pyteal file and use code to replace those before compiling the pyteal to teal?

1 Like

Ok i got the issue with my approach. So you suggest to use some sort of Python compiling mechanism inside my java application, so i can go from PyTeal → Teal → LogicSig, all inside my application so that every parameter is covered by the signature of the user that releases the contract, right?

Yes but they would not be parameters to the contract but template values that are replaced before compiling. I do a similar thing in the DEX example I wrote: Algorand Developer Portal
Specifically in the source: smart-contracts/dex.js at master · algorand/smart-contracts · GitHub