I would like to have a condition in a state contract that depends on an agreed rule between the parties involved. I don't want to hardcode this rule as the parties may want to agree to update the rule later. For example:
//'y' is an agreed value between the participants.
if (inputThingState.amount > y) {
"If thing amount is greater than y, then status must equal 1" using outputThingState.status == 1
}
One way of doing this is to have a Rule State object, which is proposed and agreed by the relevant parties in a prior transaction. Then add the approved Rule state object as an input to the current transaction. Therefore the condition would look like this:
if (inputThingState.amount > inputRuleState.y) {
"If thing amount is greater than y, then status must equal 1" using outputThingState.status == 1
}
This seems to work but it means that the RuleState object is consumed, so it must be copied and added as an output state, so that it is available to use again. It could also cause problems as multiple transactions might want to consume the same RuleState at the same time.
Is there a more elegant way of achieving this? (Possibly by passing in the approved rule as Command data.)