1

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. enter image description here

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

3
  • How about troubleshooting by replacing Constraints.mustBeSignedBy (freelancer fc) with mempty? The Wallet sending the transaction might not belong to freelancer fc
    – Aoaddeola
    Oct 20 at 3:33
  • I tried that too! Same error. Maybe my StateMachine setup is where the bug is... Oct 20 at 12:50
  • Did you implement the smCheck function?
    – Aoaddeola
    Oct 20 at 12:55
2

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" :)

2
  • Great minds think alike ;) Oct 20 at 13:34
  • True that!!! xD
    – Aoaddeola
    Oct 20 at 21:24
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

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.