3

What exactly this function is validating?

checkMintedSymbol :: Bool
checkMintedSymbol = case flattenValue (txInfoMint info) of
    [(cs', _, _)] -> cs' == ownCurrencySymbol ctx
    _             -> False


info :: TxInfo
info = scriptContextTxInfo ctx 

ctx is a ScriptContext

1
  • At first glance, it appears to be some kind of redundancy. But I think it's used to ensure that the CurrencySymbol of the token (or Value) being minted is the same as the CurrencySymbol associated with the Validator/Minting Policy
    – Aoaddeola
    Sep 28 '21 at 19:11
2

It validates whether the minted value matches ownCurrencySymbol which in turn is a hash of the validator/minting policy.

The checkMintedSymbol function might be redundant as you cannot mint arbitrary currency without providing matching validator/minting policy.

Edit based on comments: it isn't redundant if there are multiple minting policies in the transaction and it ensures only one kind of currency is being minted.

2
  • 3
    It's not exactly redundant. It is saying you are only minting one kind (typically you can mint with other policies in the same tx, so in a way this is over-constrained), and it is also saying it doesn't care about the token name (as long as it's all the same) or the amount minted. Sep 28 '21 at 23:03
  • 1
    Oh, that makes sense now since the validator sees all the mints of the tx not only its "own".
    – sorki
    Sep 29 '21 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.