<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>

CC BY-SA 4.0
2022-02-03T14:15:53.303Z
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.
Martin Drozdík
CC BY-SA 4.0
2022-02-03T17:00:02.513Z
Yes! Thank you, I updated to the latest plutus-starter project, and it is working as intended!
Martin Drozdík
CC BY-SA 4.0
2022-02-03T14:05:38.437Z
2022-02-03T14:05:38.437Z
Sebastian Nagel
<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>

<plutus><statemachines>
StateMachine - keep the same value for the next state
# StateMachine - keep the same value for the next state

(Asked by: username_0 on 2022-02-03)

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.

**Tags:** plutus, statemachines

---

## 1 answers

### Answer by username_1 on 2022-02-03. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: 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.  
> **username_0**: Yes! Thank you, I updated to the latest plutus-starter project, and it is working as intended!  

---

