I have attached a token to the datum and sent it to the smart contract, now I need the validator to check that the token has a certain policy ID before it allows the contract to proceed.
How do I do that?
You can use the following
info :: TxInfo
info = scriptContextTxInfo ctx
inputValue :: [Value]
inputValue = map (txOutValue . txInInfoResolved) (txInfoInputs info)
checkValueHasToken :: Value -> Bool
checkValueHasToken val = case flattenValue val of
(pol, tn, amt) -> pol == knownPolicyID
checkInputHasToken :: Bool
checkInputHasToken = any checkValueHashToken inputValue
<policy id>.<token name>
as aBuiltinByteString
? I'm asking since the Datum is supposed to only have data