<p>The problem is most probably caused by an omitted <code>check</code> function. Even if you do not use it, you have to specify it.</p>
<p>Example:</p>
<pre><code>check :: FreelanceContract -&gt; FContractDatum -&gt; FContractRedeemer -&gt; ScriptContext -&gt; Bool
check _ _ _ _ = True

...

fCStateMachine :: FreelanceContract -&gt; StateMachine FContractDatum FContractRedeemer
fCStateMachine fc = StateMachine
{ smTransition = transition fc
, smFinal = final
, smCheck = check fc
, smThreadToken = blah blah
}
</code></pre>
<p>with the assumption that the function pointing to your final state is <code>final</code> and your <code>ThreadToken</code> &quot;blah blah&quot; :)</p>

CC BY-SA 4.0
2021-10-20T13:34:10.480Z
Great minds think alike ;)
Isaac Padberg
CC BY-SA 4.0
2021-10-20T21:24:21.497Z
True that!!! xD
Aoaddeola
CC BY-SA 4.0
2021-10-20T13:07:45.453Z
2021-10-20T13:26:18.603Z
2021-10-20T13:26:18.603Z
Aoaddeola
<p>My StateMachine does not need any additional checks with the smCheck so I completely removed the field. The compiler complained only a little bit and gave me a warning that I had an uninitialized field. Turns out, this field is required for any transitions to be valid.</p>
<p>I added in this function which always returns True and the error was fixed.</p>
<pre><code>check :: FContractDatum -&gt; FContractRedeemer -&gt; ScriptContext -&gt; Bool
check _ _ _ = True
</code></pre>

CC BY-SA 4.0
2021-10-20T13:19:04.987Z
2021-10-20T13:19:04.987Z
Isaac Padberg
<p>Transition function throws an error. Here it is.</p>
<pre><code>transition :: FreelanceContract -&gt; State FContractDatum -&gt; FContractRedeemer -&gt; Maybe (TxConstraints Void Void, State FContractDatum)
transition fc s r =
    case (stateValue s, stateData s, r) of
        _ -&gt; Just (Constraints.mustBeSignedBy (freelancer fc) , State (FContractDatum 1 (Just 0)) (lovelaceValueOf 2))
</code></pre>
<p>Here is the wallet code for submitting the transaction</p>
<pre><code>    case m of
        Nothing             -&gt; throwError &quot;Contract ouput not found&quot;
        Just ((o, _), _) -&gt; case tyTxOutData o of

            FContractDatum 0 Nothing -&gt; do
                logInfo @String &quot;Contract found. Accepting...&quot;
                void $ mapError' $ runStep client Accept
                logInfo @String &quot;Contract Accepted&quot;

            _ -&gt; throwError &quot;unexpected datum&quot;
</code></pre>
<p>And here is the error that is thrown when I run my trace.
<a href="https://i.sstatic.net/ayMcH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ayMcH.png" alt="enter image description here" /></a></p>
<p>I have boiled this code down to its simplest parts, but still, the error persists. :/</p>

CC BY-SA 4.0
2021-10-20T03:33:54.270Z
How about troubleshooting by replacing `Constraints.mustBeSignedBy (freelancer fc)` with `mempty`? The Wallet sending the transaction might not belong to `freelancer fc`
Aoaddeola
CC BY-SA 4.0
2021-10-20T12:50:52.457Z
I tried that too! Same error. Maybe my StateMachine setup is where the bug is...
Isaac Padberg
CC BY-SA 4.0
2021-10-20T12:55:11.530Z
Did you implement the `smCheck` function?
Aoaddeola
<statemachines><validation><error>
StateMachine validation failing
# StateMachine validation failing

(Asked by: username_0 on 2021-10-19)

Transition function throws an error. Here it is.
transition :: FreelanceContract -> State FContractDatum -> FContractRedeemer -> Maybe (TxConstraints Void Void, State FContractDatum)
transition fc s r =
    case (stateValue s, stateData s, r) of
        _ -> Just (Constraints.mustBeSignedBy (freelancer fc) , State (FContractDatum 1 (Just 0)) (lovelaceValueOf 2))

Here is the wallet code for submitting the transaction
    case m of
        Nothing             -> throwError "Contract ouput not found"
        Just ((o, _), _) -> case tyTxOutData o of

            FContractDatum 0 Nothing -> do
                logInfo @String "Contract found. Accepting..."
                void $ mapError' $ runStep client Accept
                logInfo @String "Contract Accepted"

            _ -> throwError "unexpected datum"

And here is the error that is thrown when I run my trace.

I have boiled this code down to its simplest parts, but still, the error persists. :/

**Tags:** statemachines, validation, error
> **Comments:**
> **username_1**: How about troubleshooting by replacing `Constraints.mustBeSignedBy (freelancer fc)` with `mempty`? The Wallet sending the transaction might not belong to `freelancer fc`  
> **username_0**: I tried that too! Same error. Maybe my StateMachine setup is where the bug is...  
> **username_1**: Did you implement the `smCheck` function?  

---

## 2 answers

### Answer by username_1 on 2021-10-20. Score: 2 | Accepted answer

The problem is most probably caused by an omitted check function. Even if you do not use it, you have to specify it.
Example:
check :: FreelanceContract -> FContractDatum -> FContractRedeemer -> ScriptContext -> Bool
check _ _ _ _ = True

...

fCStateMachine :: FreelanceContract -> StateMachine FContractDatum FContractRedeemer
fCStateMachine fc = StateMachine
{ smTransition = transition fc
, smFinal = final
, smCheck = check fc
, smThreadToken = blah blah
}

with the assumption that the function pointing to your final state is final and your ThreadToken "blah blah" :)

> **Comments:**
> **username_0**: Great minds think alike ;)  
> **username_1**: True that!!! xD  

---

### Answer by username_0 on 2021-10-20. Score: 2

My StateMachine does not need any additional checks with the smCheck so I completely removed the field. The compiler complained only a little bit and gave me a warning that I had an uninitialized field. Turns out, this field is required for any transitions to be valid.
I added in this function which always returns True and the error was fixed.
check :: FContractDatum -> FContractRedeemer -> ScriptContext -> Bool
check _ _ _ = True


---

