In HW 2 of Week 5, we need to write a script that mints a token with empty ByteString. The minting policy code on the on-chain part (mkPolicy) could ensure that the token name is empty by defining

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
      [(_, tn, amt)] -> tn == (TokenName emptyByteString) && amt == 1
      _              -> False

I claim that that the weaker constraint

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoMint info) of
      [(_, _, amt)] -> amt == 1
      _             -> False

is good enough, since the off-chain part of the code will make sure that the token name is the empty string. I ran the experiment and it seems to work.

Generalizing, it seems that the constraints on the on-chain script can be less stringent than the off-chain constraints if the transaction is going to be initiated by the wallet that owns the UTxO where the script resides. Is this claim correct?

1 Answer 1


This question was answered by Lars during the Q&A.

In summary, you can't rely on an attacker using your offchain code. An attacker could write their own off chain code that uses a non empty Token name.

Perhaps if you are sure that you are the only person able to use the minting policy (eg you check that the transaction is signed by a specific user), you could make such assumptions.

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.