Spoiler, so don't look if you haven't done the homework yet.

In the solution file Solution2.hs we have

checkSig :: Bool
checkSig = unPaymentPubKeyHash pkh `elem` txInfoSignatories info

while in the file from the lecture Vesting.hs we have the same check implemented as

signedByBeneficiary :: Bool
signedByBeneficiary = txSignedBy info $ unPaymentPubKeyHash $ beneficiary dat

I get the same behavior in the playground with the two implementations in Solution2.hs, and moreover looking at the implementation of txSignedBy

{-# INLINABLE txSignedBy #-}
-- | Check if a transaction was signed by the given public key.
txSignedBy :: TxInfo -> PubKeyHash -> Bool
txSignedBy TxInfo{txInfoSignatories} k = case find ((==) k) txInfoSignatories of
    Just _  -> True
    Nothing -> False

I don't see a difference. Maybe my tests in the playground aren't good enough, but is there an example of different behavior?

1 Answer 1


They are the same. I'd say the signedByBeneficiary way is more idiomatic.

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.