3

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"
2
  • Are you running using nix-shell? Aug 16 at 5:34
  • @MitchellTurner yes I am - loving nix atm.
    – alanionita
    Aug 16 at 13:36
4

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.

1
  • 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
    Aug 16 at 13:39

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.