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?

1 Answer 1


You want immutability in a particular variable of the contracts state. Change in state in Plutus/Cardano is done by creating a new state that passes a validation function. In order to prevent the variable changing, you need to make your validation function reject them being different.

  • Is this possible to be done on-chain?
    – FTM
    Jan 15 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.