1

In week 5 of plutus-pioneer-program with NFT example this plutus minting policy code is provided:

{-# INLINABLE mkPolicy #-}
mkPolicy :: TxOutRef -> TokenName -> () -> ScriptContext -> Bool
mkPolicy oref tn () ctx = traceIfFalse "UTxO not consumed"   hasUTxO           &&
                          traceIfFalse "wrong amount minted" checkMintedAmount
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    hasUTxO :: Bool
    hasUTxO = any (\i -> txInInfoOutRef i == oref) $ txInfoInputs info

    checkMintedAmount :: Bool
    checkMintedAmount = case flattenValue (txInfoForge info) of
        [(cs, tn', amt)] -> cs  == ownCurrencySymbol ctx && tn' == tn && amt == 1
        _                -> False

Script validates if minted NFT is 1. Here are my questions regarding one-time minting:

  • Is this an example of a one-time policy script which is referenced in Cardano documentation here ?
  • If this is a one-time minting policy, how does it ensure that only one and only NFT is to be minted with this minting policy? What stops me of instead minting many NFS with single transaction creating many transactions to mint many NFTS one by one?
  • If this is not a one-time minting policy, how does one-time policy actually look like? How does it ensure that only one token or NFT is to be minted in Cardano network?
  • Is it possible and if so how to secure the total amount to be minted with minting policy? How would simplest example of that plutus script code look like?
  • Is it possible to create such minting policy, that it allow to mint only if total minted token amount is not reached and if so how?
  • Is it possible to create such minting policy, that total amount to be minted is dependent on the time (slot). For example by Monday total amount minted can be 10000, but by Tuesday it can be 20000?
0

1 Answer 1

1

Yes, this is an example of a "one-time minting policy" referred to in the Cardano documentation.

The policy ensures that only one NFT is minted by a combination of i) being parametrised with a specific UTxO that needs to be consumed by the transaction (checked by hasUTxO) and ii) checking that the total mint quantity is 1. As all UTxOs are unique, this policy can only succeed one time and then never again. The parametrisation ensures that the NFT currency symbol depends on this UTxO, so that if you define the same policy with another UTxO it would not be the same NFT.

I did not understand the question in bullet point 4.

To get a minting policy that allows to mint up to a total fixed supply, I would combine the policy with a script UTxO that keeps track of the minted value in the datum. You need to put an NFT in this script UTxO as well and the minting policy would need to check the presence of it in the transaction and delegate the validation to the script. The script can then check the newly minted value and apply some logic, like checking the weekday. But it would be much easier to just mint the total quantity in one transaction and then distribute the tokens with another mechanism.

2
  • Is it possible to read Datum values in UTXO from plutus policy script?
    – KugisMugis
    Jan 5 at 8:19
  • 1
    Minting policies also get a ScriptContext passed to. Through this context you can access the datums of the transaction inputs and outputs.
    – Jey
    Jan 8 at 16:00

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.