user6316: 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.

user387: 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.

6316: <p>I work with the StateMachine library, and I need to transition from state to another where the <code>stateValue</code> of the <code>State</code> 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 <code>stateValue</code> of a <code>State</code> already includes the thread token, but it is added one more time or something like that. In summary, I have this (simplified):</p>
<pre><code>{-# INLINABLE transition #-}
transition :: ContractParam -&gt; State ContractDatum -&gt; ContractRedeemer -&gt; Maybe (TxConstraints Void Void, State ContractDatum)
transition cParam cState cRedeemer = 
  ...

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

  ...
</code></pre>
<p>To summarize, I need to keep the same <code>stateValue</code> into the next state but get insufficient funds error, so I presume I need something like <code>(stateValue cState) - threadToken</code> except the threadToken is not of type Value and I can not figure out, how to convert the thread token to <code>Value</code> or how to remove the thread token from stateValue so that I don't get the insufficient funds error.</p>
<hr />
<p>Edit: The code snippet should work as is, but there was a bug. The newest plutus versions work.</p>
 387: <p>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 <code>plutus-apps</code> (repository was split in two) might help already.</p>
