When creating a script, the script is given a script address. If I would like to run multiple scripts in parallel, how to go about that? Do I have to define a nonce variable just to make the address different?
1 Answer
Does a script always have the same address forever?
Yes. But the script doesn't live at the address, transactions spending UTxOs at the address must be validated by the script to be spent.
When creating a script, the script is given a script address.
A script address literally is just a hash of script code. It's not given, it can be deterministically derived by anyone with the script code.
If I would like to run multiple scripts in parallel, how to go about that?
For Validator scripts, the script is only "run" when trying to redeem a Datum at the script address. You can have many Datums at a validator address though. That could be thought of as many parallel instances at the same address--depending on how the contract is written. Although, some scripts might require multiple Datums are spent simultaneously, etc.
Do I have to define a nonce variable just to make the address different?
Yes. Depending on how you write your script, it might be useful to have separate scripts for separate parameters (see here). But if you want exactly the same behavior for each "instance" I suggest you think of the Datum as being the separate instance.