user2228: I am using state machines to create a smart contract. How can I create a variable that will be defined by the user when it runs the first step of the state machine and that then can't be modified anymore?
In other words, it's a variable that is created by using the smart contract endpoints but that can't be modified later on until the state machine reaches its end.
Finally, would it be possible to make this validation on-chain?

user6089: You could modify your datum type to something like so: {constants: {...}, old_datum: {...}}
Then, make your old validations take old_datum (you could unwrap old_datum as the same name as your current datum even), and validate output constants==input constants. You will want an exception to this rule if the input does not come from the script, to allow setting the constants at first, so you could logically enforce something like "for each input utxo, if that input resided at this script, enforce that there is some unique output utxo with the same constants".

2228: <p>I am using state machines to create a smart contract. How can I create a variable that will be defined by the user when it runs the first step of the state machine and that then can't be modified anymore?</p>
<p>In other words, it's a variable that is created by using the smart contract endpoints but that can't be modified later on until the state machine reaches its end.</p>
<p>Finally, would it be possible to make this validation on-chain?</p>
 6089: <p>You could modify your datum type to something like so: {constants: {...}, old_datum: {...}}</p>
<p>Then, make your old validations take old_datum (you could unwrap old_datum as the same name as your current datum even), and validate output constants==input constants. You will want an exception to this rule if the input does not come from the script, to allow setting the constants at first, so you could logically enforce something like &quot;for each input utxo, if that input resided at this script, enforce that there is some unique output utxo with the same constants&quot;.</p>
