I want to create a NFT collection in which the creator does not have to mint the NFT's but the consumer does through a smart contract that they interact with. Would this be possible to do while sill keeping the same policy ID for each NFT or is that only possible by pre-minting the NFT's and sending them to a storing wallet.
2 Answers
Yes, you can do that.
An example could be to use a sequence number in a validator script (smart contract) in conjuction with a policy.
- Validator script (smart contract) should manage the sequence number. For this, you can use the datum. Every time you mint a NFT, check that datum has increased (+1).
- Policy can be the same for all tokens. You can append to your token name, the sequence number (here you can find a function to convert integer to bytestring)
Just make sure, to use a dummy NFT in your validator script:
- To identify the right UTXO every time you mint
- To validate from the policy script that it's included in the transaction.
Here is a good explanation for that.
-
1
@georgeos answer is correct
I'd like to point out another way you could implement this:
You could use the consumer's UTxO as an input into the Token Name (it's common to use it as an parameter of the script to affect the policy name). Then you don't need to track state on a datum.
I'll mention, these methods will make the tokens non-fungible and unique, but if anyone can mint the NFTs they might not be particularly scarce--something to keep in mind. That being said, I think there are still some interesting uses for these patterns. And there would be additional ways to make the tokens scarce with time constraints, etc.
-
Would a boolean statement be a good way to stop the minting of an asset after x number of new NFT's, in the method provided.– Floof99Commented Dec 21, 2021 at 1:17
-
Yeah. Plutus scripts are all just Boolean statements, essentially. Only allowing x tokens to be made is a constraint you could add, for sure. Commented Dec 21, 2021 at 9:25
-
This method will still keep the same Policy ID for all tokens minted right?– Floof99Commented Dec 23, 2021 at 2:57