We want to associate multiple policy ids with the same token/nft. Is this possible?
2 Answers
as @Fermat already answered
Currently Value is parametrized by a currency symbol and a token name. Here the currency symbol is not arbitrary, it is the hash of the minting policy script. This script determines under which conditions the tokens under this policy can be minted or burned.
so NO you cannot have multiple policy ids for the same token since then we wouldn't know how to properly mint/burn it.
what you could do instead is to associate multiple validators to the policy which is supposed to mint or burn you token or NFT.
as an example say you want to check for validatorA
and validatorB
to both have signed the transaction (therefore have been executed with success) and validatorC
to succeed in order to burn
your minting policy would look like this:
mintingPolicyLogic :: BuiltinData -> ScriptContext -> Bool
mintingPolicyLogic _red ctx =
if isMinting then
validatorASucceeded &&
validatorBSucceeded
else
validatorCSucceeded
where
validatorSucceded :: ValidatorHash -> Bool
validatorSucceded valHash = forwardToValidator valHash () ctx
validatorASucceeded = validatorSucceded <insert validatorA hash here>
validatorBSucceeded = validatorSucceded <insert validatorB hash here>
validatorCSucceeded = validatorSucceded <insert validatorC hash here>
isMinting = case Value.flattenValue (LedgerApi.txInfoMint txInfo) of
[] -> False
[( _sym, _tn, amount )] -> amount > 0
_ -> traceError "multiple mints per tx not allowed"
NOTE: the script provided is by no mean production ready, lots of improvements can (and should) be made, the script is here for educational purposes only
-
Note that a mintingPolicy only uses a redeemer and the context, not a datum.– FermatCommented Jun 22, 2022 at 12:37
-
Currently Value
is parametrized by a currency symbol, a tokenname and the amount of tokens of this type(1). Here the currency symbol is not arbitrary, it is the hash of the minting policy script. This script determines under which conditions the tokens under this policy can be minted or burned.
To answer your question, it depends. If you want tokens with the same Tokenname and different policies, then yes. But if you want one token with currency symbol x
and tokenname y
that you can mint via multiple minting policies that both hash to x
, then no.
Perhaps you could specify what you want to do with the token? If you just want two condition that both can mint/burn you could always combine two minting policies to get one policy.