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?