4

I wish to write a script that will automatically mint NFTs given payment to an address. Firstly, I haven't found anyone that has shown how to do this, but if anyone has, or is willing to share, please let me know.

I notice the tutorial here suggests using cardano-cli, however, this requires cardano-node to be running which seems very brittle to me, because if you have issues keeping up with the current state of the blockchain, then you'll miss out on payments. https://developers.cardano.org/docs/integrate-cardano/listening-for-payments-cli/

Would using cardano-wallet be a better or safer option to listen for transactions?

What would be the steps to automatically minting NFTs based on payment? And would anyone have any recommendations on how you'd host the script once you've written it? Would you have cardano-node constantly running in a virtual machine (e.g. EC2 instance).

2

setting up the cardano node is very simple, and once set-up, as long as your resource is available, the node stays up-to-date with the blockchain. The CoinCashew tutorial (https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node#14-configure-your-topology-files) is great for this & there are a number of YouTube videos that explain what do to do too (although tip from my experience, avoid DigitalOcean as a provider for VMs).

I then used this tutorial (https://developers.cardano.org/docs/native-tokens/minting/), to mint NFTs using the cardano-cli & it worked great. I would imagine that based on this, it shouldn't be too complicated to derive a script to do it automatically.

Unfortunately, I cannot help you on your "minting on payment" answer as I am also just beginning to look into this. Also, I'm sure the new smart contracts would have that functionality?

0

Look into dbsync as that is how you can actually look at transactions and not just the txhashes.

Basic setup would be dbsync server (postgres) + cnode (cli || wallet):

dbsync

  1. query slot every couple seconds to see if new block (new block means new potential transactions)
  2. if new block, then grab any new transactions that meet your criteria (verify the amount of ada and grab the addr)

cli / wallet

  1. Send to minting script and mint and send in same tx :)

side notes

  • either mint 1 at a time, or do about 30 at a time in one tx.
  • If you need to do more then 30 you will need multiple addresses. To make this work the address you are sending too is different from the addresses you will be minting from. Assuming thousands of requests per block, you could mint 1200 NFTs, with 40 addresses, just need to keep track of them all
0

Code for minting Spacebudz is actually open-source, so you could probably use that with a bit of tweaking.

As far as I know this code should basically mint tokens in order for every new transaction back to the transaction sender.

Here's the link to source repo: https://github.com/Berry-Pool/nft-server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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