7

This is part of my attempt at solving the first homework assignment of week 5 in the plutus pioneer program. The rest of the unmodified file can be found here.

{-# INLINABLE mkPolicy #-}
-- This policy should only allow minting (or burning) of tokens if the owner of the specified PubKeyHash
-- has signed the transaction and if the specified deadline has not passed.
mkPolicy :: PubKeyHash -> Slot -> ScriptContext -> Bool
mkPolicy pkh deadline ctx = traceIfFalse "Valid signature missing" signed &&
                            traceIfFalse "Deadline has passed" stillTime
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    signed :: Bool
    signed = txSignedBy info pkh

    stillTime :: Bool
    stillTime = to deadline `contains` txInfoValidRange info

policy :: PubKeyHash -> Slot -> Scripts.MonetaryPolicy
policy pkh deadline = mkMonetaryPolicyScript $
    $$(PlutusTx.compile [|| \pkh' deadline' -> Scripts.wrapMonetaryPolicy $ mkPolicy pkh' deadline' ||])
    `PlutusTx.applyCode`
    PlutusTx.liftCode pkh
    `PlutusTx.applyCode`
    PlutusTx.liftCode deadline

curSymbol :: PubKeyHash -> Slot -> CurrencySymbol
curSymbol pkh deadline = scriptCurrencySymbol $ policy pkh deadline

I tested the code by loading the file into the repl and running the test. The output confirms that this seems to be the right solution.

However, when compiling the code in the playground, I get this message:

It looks like you have not made any functions available, use `$(mkFunctions ['functionA, 'functionB])` to be able to use `functionA` and `functionB`

Since endpoints is defined, the contract is made available in the simulator and I can confirm the test manually in the simulator as well.

I am just very confused by this message. Did my code introduce an uncaptured error? I compiled some of the previous files without this message. What am I missing?

2
  • I just copied your code snipet in the Homework1.hs from week 5 in the playground at playground.plutus-community.com and I dont get any errors. Can share your whole file? Commented May 11, 2021 at 7:39
  • I wanted to clarify that it still compiles, it's just a warning message that shows up in the playground on compilation. @AngelCastillo you can find the file here: raw.githubusercontent.com/manonthemat/plutus-pioneer-program/… Commented May 11, 2021 at 16:21

1 Answer 1

6

The Playground needs some boilerplate added to a module:

mkSchemaDefinitions ''NAMEOFYOURSCHEMA
mkKnownCurrencies []

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.