user4767: When modifying the week5 code in e.g. Signed.hs from
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ unPaymentPubKeyHash pkh

to the hard-coded pkh from Wallet 1,
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ PubKeyHash "a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2"

the validation fails with
CONTRACT STOPPED WITH ERROR: "\"WalletError (ValidationError (ScriptFailure (EvaluationError [\\\"PT5\\\"] \\\"CekEvaluationFailure\\\")))\""

I verified in the repl:
mockWalletPaymentPubKeyHash (knownWallet 1)
a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2

and also in the offchain code logging Contract.ownPaymentPubKeyHash gives the same a2c2...09c2 hash.
What is going wrong here?
I unsuccessfully tried to debug it with
mkPolicy pkh () ctx = traceError $ decodeUtf8 $ getPubKeyHash $ head $ txInfoSignatories (scriptContextTxInfo ctx)

which resulted in an error as well.
CONTRACT STOPPED WITH ERROR: "\"WalletError (ValidationError (ScriptFailure (EvaluationError [] \\\"BuiltinEvaluationFailure of DecodeUtf8\\\")))\""

What is the correct way to debug this? e.g. in this case to check what the pkh used in the onchain code was? Is decodeUtf8 the right function at all for BuiltinByteString -> BuiltinString in this case or is it a special byte string?

user4767: This was answered in PPP Q&A, the issue was the string literals in Plutus Core code.
Instead, one has to use variables
{-# INLINABLE mkPolicy #-}
mkPolicy :: PaymentPubKeyHash -> () -> ScriptContext -> Bool
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ 
unPaymentPubKeyHash pkh

and put the literal into the liftCode expression:
policy :: Scripts.MintingPolicy
policy = mkMintingPolicyScript $
$$(PlutusTx.compile [|| Scripts.wrapMintingPolicy . mkPolicy ||])
`PlutusTx.applyCode`
PlutusTx.liftCode (PaymentPubKeyHash "a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2")


4767: <p>When modifying the week5 code in e.g. Signed.hs from</p>
<pre><code>mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ unPaymentPubKeyHash pkh
</code></pre>
<p>to the hard-coded pkh from Wallet 1,</p>
<pre><code>mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ PubKeyHash &quot;a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2&quot;
</code></pre>
<p>the validation fails with</p>
<pre><code>CONTRACT STOPPED WITH ERROR: &quot;\&quot;WalletError (ValidationError (ScriptFailure (EvaluationError [\\\&quot;PT5\\\&quot;] \\\&quot;CekEvaluationFailure\\\&quot;)))\&quot;&quot;
</code></pre>
<p>I verified in the repl:</p>
<pre><code>mockWalletPaymentPubKeyHash (knownWallet 1)
a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2
</code></pre>
<p>and also in the offchain code logging Contract.ownPaymentPubKeyHash gives the same a2c2...09c2 hash.</p>
<p>What is going wrong here?</p>
<p>I unsuccessfully tried to debug it with</p>
<pre><code>mkPolicy pkh () ctx = traceError $ decodeUtf8 $ getPubKeyHash $ head $ txInfoSignatories (scriptContextTxInfo ctx)
</code></pre>
<p>which resulted in an error as well.</p>
<pre><code>CONTRACT STOPPED WITH ERROR: &quot;\&quot;WalletError (ValidationError (ScriptFailure (EvaluationError [] \\\&quot;BuiltinEvaluationFailure of DecodeUtf8\\\&quot;)))\&quot;&quot;
</code></pre>
<p>What is the correct way to debug this? e.g. in this case to check what the pkh used in the onchain code was? Is decodeUtf8 the right function at all for BuiltinByteString -&gt; BuiltinString in this case or is it a special byte string?</p>
 4767: <p>This was answered in PPP Q&amp;A, the issue was the string literals in Plutus Core code.
Instead, one has to use variables</p>
<pre><code>{-# INLINABLE mkPolicy #-}
mkPolicy :: PaymentPubKeyHash -&gt; () -&gt; ScriptContext -&gt; Bool
mkPolicy pkh () ctx = txSignedBy (scriptContextTxInfo ctx) $ 
unPaymentPubKeyHash pkh
</code></pre>
<p>and put the literal into the liftCode expression:</p>
<pre><code>policy :: Scripts.MintingPolicy
policy = mkMintingPolicyScript $
$$(PlutusTx.compile [|| Scripts.wrapMintingPolicy . mkPolicy ||])
`PlutusTx.applyCode`
PlutusTx.liftCode (PaymentPubKeyHash &quot;a2c20c77887ace1cd986193e4e75babd8993cfd56995cd5cfce609c2&quot;)
</code></pre>
