Minting policies are very similar to StakeValidators in the sense that they also do not receive the datum argument for validation, only the redeemer and context. This type of policy is used for the Minting CurrencySymbol script purpose. It returns a () representing a valid minting or burning transaction or throws an error if validation fails. But when using typed minting policy scripts, the function should return a boolean value.

As introduced in the Introduction to the EUTxO model section, tokens on Cardano are made up of the CurrencySymbol and the token name. One CurrencySymbol can hold an infinite number of TokenNames. Token names are generally hexified ByteStrings but have an ASCII representation as well. CurrencySymbol is the hash of the minting policy that controls token minting/burning.

Before Plutus, these policies were introduced in the Mary era and simple timelocking minting policies were already possible. Now with Plutus, we can control the minting policy with arbitrary logic instead of just key witnesses and timelocks. So CurrencySymbol is the hash of the minting policy, whether it's a Plutus policy script or a Mary-era style policy (CurrencySymbol is also referred to as the policyID).

To create minting policies with Plutus, we use the mkMintingPolicyScript function, which accepts a function of BuiltinData -> BuiltinData -> () of CompiledCode and returns a MintingPolicy - a wrapper around the Script type. The function of type BuiltinData -> BuiltinData -> () represents the untyped version of the minting policy created with the mkUntypedMintingPolicy method.

mkMintingPolicyScript :: 
    CompiledCode (BuiltinData -> BuiltinData -> ())
    -> MintingPolicy

mkUntypedMintingPolicy :: 
    UnsafeFromData r =>
        (r -> sc -> Bool) -> UntypedMintingPolicy

In the next section, we will write a pay-to-store minting policy script.

Last updated