<p>The local playground code is compiled to a version that is too recent for week 2. It needs to be compile to the correct commit for week 2. The change to BuiltinData only happened at week 04.</p>
<p>Check the Plutus repo out at the week 2 commit, before executing nix-shell. The commit can be found in the plutus-pioneer-program repo in folder code/week02, file cabal.project at line 28.</p>

CC BY-SA 4.0
2021-08-16T13:39:30.157Z
I will try that next. I'd also love to fix the issues in case I hit this problem later. Seems like the contract for `PlutusTx.toData` is now `PutusTx.IsData.toData` (from the docs), but that new interface also triggers a compile error
alanionita
CC BY-SA 4.0
2021-08-16T13:15:28.870Z
2021-08-16T13:15:28.870Z
vcwebco
<p>Working through the Plutus Pioneer Week2 homework and getting the following error in the locally served playground.</p>
<pre><code>error:
    • Couldn't match expected type ‘BuiltinData’
                  with actual type ‘PlutusTx.Data’
    • In the second argument of ‘($)’, namely ‘PlutusTx.toData bs’
      In the second argument of ‘($)’, namely
        ‘Redeemer $ PlutusTx.toData bs’
      In the expression:
        mustSpendScriptOutput oref $ Redeemer $ PlutusTx.toData bs
   |
77 |         tx      = mconcat [mustSpendScriptOutput oref $ Redeemer $ PlutusTx.toData bs | oref &lt;- orefs]
   |                 

</code></pre>
<p>Validator code in question</p>
<pre><code>import           Plutus.Contract
import qualified PlutusTx
import           PlutusTx.Prelude     hiding (Semigroup(..), unless)

...

grab :: forall w s e. AsContractError e =&gt; (Bool, Bool) -&gt; Contract w s e ()
grab bs = do
    utxos &lt;- utxoAt scrAddress
    let orefs   = fst &lt;$&gt; Map.toList utxos
        lookups = Constraints.unspentOutputs utxos      &lt;&gt;
                  Constraints.otherScript validator
        tx :: TxConstraints Void Void
        tx      = mconcat [mustSpendScriptOutput oref $ Redeemer $ PlutusTx.toData bs | oref &lt;- orefs]
    ledgerTx &lt;- submitTxConstraintsWith @Void lookups tx
    void $ awaitTxConfirmed $ txId ledgerTx
    logInfo @String $ &quot;collected gifts&quot;
</code></pre>

CC BY-SA 4.0
2021-08-16T05:34:00.393Z
Are you running using nix-shell?
Mitchell Turner
CC BY-SA 4.0
2021-08-16T13:36:27.397Z
@MitchellTurner yes I am - loving nix atm.
alanionita
<plutus-pioneer-program><plutustx>
Couldn't match expected type ‘BuiltinData’ in locally run playground
# Couldn't match expected type ‘BuiltinData’ in locally run playground

(Asked by: username_0 on 2021-08-15)

Working through the Plutus Pioneer Week2 homework and getting the following error in the locally served playground.
error:
    • Couldn't match expected type ‘BuiltinData’
                  with actual type ‘PlutusTx.Data’
    • In the second argument of ‘($)’, namely ‘PlutusTx.toData bs’
      In the second argument of ‘($)’, namely
        ‘Redeemer $ PlutusTx.toData bs’
      In the expression:
        mustSpendScriptOutput oref $ Redeemer $ PlutusTx.toData bs
   |
77 |         tx      = mconcat [mustSpendScriptOutput oref $ Redeemer $ PlutusTx.toData bs | oref <- orefs]
   |                 


Validator code in question
import           Plutus.Contract
import qualified PlutusTx
import           PlutusTx.Prelude     hiding (Semigroup(..), unless)

...

grab :: forall w s e. AsContractError e => (Bool, Bool) -> Contract w s e ()
grab bs = do
    utxos <- utxoAt scrAddress
    let orefs   = fst <$> Map.toList utxos
        lookups = Constraints.unspentOutputs utxos      <>
                  Constraints.otherScript validator
        tx :: TxConstraints Void Void
        tx      = mconcat [mustSpendScriptOutput oref $ Redeemer $ PlutusTx.toData bs | oref <- orefs]
    ledgerTx <- submitTxConstraintsWith @Void lookups tx
    void $ awaitTxConfirmed $ txId ledgerTx
    logInfo @String $ "collected gifts"

**Tags:** plutus-pioneer-program, plutustx
> **Comments:**
> **username_1**: Are you running using nix-shell?  
> **username_0**: @MitchellTurner yes I am - loving nix atm.  

---

## 1 answers

### Answer by username_2 on 2021-08-16. Score: 4 | Accepted answer

The local playground code is compiled to a version that is too recent for week 2. It needs to be compile to the correct commit for week 2. The change to BuiltinData only happened at week 04.

Check the Plutus repo out at the week 2 commit, before executing nix-shell. The commit can be found in the plutus-pioneer-program repo in folder code/week02, file cabal.project at line 28.

> **Comments:**
> **username_0**: I will try that next. I'd also love to fix the issues in case I hit this problem later. Seems like the contract for `PlutusTx.toData` is now `PutusTx.IsData.toData` (from the docs), but that new interface also triggers a compile error  

---

