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?