1

If I have a wallet that currently stores x amount of NFT's and I make a validator script that provides one NFT from that wallet in exchange for ADA what would I call to make sure 1 unique NFT goes out to each caller of the said validator script? Specifically how would the validator script know which NFT to give out? Is there a way to sort out metadata of NFT's using script context and pick the next NFT to send out by its number order?

2 Answers 2

0

There are onchain validator scripts available like this one, which describe nicely how it can be done.

nft-plutus by Berry Pool

-2

The way that my vending machine does it is that I store all of the total NFT collection in a MongoDB. Then, when my script sees a sale UTXO come into a wallet, it queries the MongoDB for any NFT that is still 'available' and pulls them all down into an array. I then shuffle the array and mint the one in the [0] spot. Finally, I mark the NFT as sold in MongoDB.

1
  • This question is about plutus, not offchain solutions.
    – eddex
    Jan 26, 2022 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.