A Pay-to-Store Policy
Writing the validator
data TokenSaleParams = TokenSaleParams
{
store :: PlutusV2.Address, -- public address of the token store
tName :: PlutusV2.TokenName, -- name of the token to be minted
tPrice :: Integer -- price in ADA per token
}
PlutusTx.unstableMakeIsData ''TokenSaleParams
PlutusTx.makeLift ''TokenSaleParamsmkPolicy :: TokenSaleParams -> BuiltinData -> PlutusV2.ScriptContext -> Bool
mkPolicy tsp _ ctx = traceIfFalse "Invalid mint" checkMint
where
info :: PlutusV2.TxInfo
info = PlutusV2.scriptContextTxInfo ctx
txOuts :: [PlutusV2.TxOut]
txOuts = PlutusV2.txInfoOutputs infoTesting the validator
Last updated