1

I work with the StateMachine library, and I need to transition from state to another where the stateValue of the State is exactly the same. The problem is that when I try to do the transition, I get an error that the user has insufficient funds pointing at the thread token. I presume that the stateValue of a State already includes the thread token, but it is added one more time or something like that. In summary, I have this (simplified):

{-# INLINABLE transition #-}
transition :: ContractParam -> State ContractDatum -> ContractRedeemer -> Maybe (TxConstraints Void Void, State ContractDatum)
transition cParam cState cRedeemer = 
  ...

     -- This is simply what I need to transition to
     Just(mempty, State ("some updated datum") (stateValue cState))

  ...

To summarize, I need to keep the same stateValue into the next state but get insufficient funds error, so I presume I need something like (stateValue cState) - threadToken except the threadToken is not of type Value and I can not figure out, how to convert the thread token to Value or how to remove the thread token from stateValue so that I don't get the insufficient funds error.


Edit: The code snippet should work as is, but there was a bug. The newest plutus versions work.

1 Answer 1

2

Which version of plutus are you using? IIRC a problem like that was fixed in the last couple of months and maybe updating your dependencies to the latest plutus-apps (repository was split in two) might help already.

2
  • I am using an older plutus from time of plutus pioneer program #2. I am not sure what plutus version is that but I will try updating it. Commented Feb 3, 2022 at 14:15
  • Yes! Thank you, I updated to the latest plutus-starter project, and it is working as intended! Commented Feb 3, 2022 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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