Efficient Minting of NFTs

I’m writing some code to process payments and mint NFTs in return. I’m currently trying to determine the best architecture to efficiently mint the NFTs when receiving a high volume of payments.

Once a minute minute my software wakes up to collect all the incoming UTXOs received. Then it determines how many NFTs to mint for each UTXO received, submits a single transaction with all the UTXOs as input and delivering the minted NFT along with min ADA to the corresponding address for each UTXO. On testnet this has been working well, minting up to 50 NFTs to 10 recipients in a single transaction.

However, for some of the big projects that have recently been minted I noticed that each NFT is minted in a single transaction. Am I missing something? Is there a reason they choose to process only a single UTXO at a time?

2 Likes

No, you’re not missing anything. It is less costly to bundle several mintings into a single transaction. Even with long names and the 721 metadata, fifty NFTs should fit in a single transaction.

The other projects might use single-UTxO transactions because (1) they can mint right away (not wait up to a minute), (2) their software can have simpler logic, or (3) users can easily see the relationship between their UTxO and their receiving the NFT.

2 Likes

It may depend on the purpose of the token.

Batching makes sense for uniform token format in high demand and/or high volume.
In contrast I’ll use myself as an example.

My project will generate one token per transaction as the token confers both identity and access to the other features of the application. In short, the token is the player character for an edutainment game.

In long, most users will only ever need one token at the cost of roughly 2 ADA. There is no reason for me to batch this and make any single user artificially wait as I doubt I will have more than one registration per minute anyway (using your ingestion schedule). I would rather have a better user experience than saving a marginal amount of ADA in transaction fee reduction. If for some bizarre reason my project to teach myself about Cardano while teaching others about Cardano becomes ludicrously popular then that’s a problem I would love to solve at that time.

SWE 101:
Solve problems when present. Plan to have problems. Write code for plans that change.

2 Likes

hi there,

how do you get the transaction details and the address of the wallet that paid the amount so you can send them the NFT after minting?

I am working on an NFT minter page and I am having some trouble finding the best commands to do this or I am missing something.

Did you use anything other than cardano-cli?

Thanks

1 Like

I use cardano-db-sync to query the transaction inputs of the UTXO. There is a sample query to do this here: cardano-db-sync/interesting-queries.md at master · input-output-hk/cardano-db-sync · GitHub

I imagine some of the online API providers such as blockfrost and dandelion would also have a function to return this data but I haven’t looked at them.

1 Like

I recommend using smart contracts now that they are available mainnet as well as developing better solutions. cardano-db-sync still has use cases (Oracles, Scanners, etc) and I also prefer Postgres over proprietary SQL databases but it should not be needed with PAB integration.

We can applaud projects like SpaceBudz for discovering clever workaround hacks for minting native tokens in creative ways but that was never intended to be a long term or scalable solution for creating or selling tokens.

1 Like

It looks like all projects are still minting NFTs as native tokens outside a smart contract. I would like to transition over to using a smart contract though. Is there any proposal, standard, or template for minting NFTs inside a smart contract?

I’m a little confused with your comment about cardano-db-sync. Is there a different, preferred way to extract the address inputs to a UTXO? Sorry, what is PAB integration?

PAB = Plutus Application Backend

I believe Week 5 of the Plutus Pioneer Program (PPP) has a very rough example of minting NFT

Of course you are welcome to use Marlowe, Glow, or other higher level abstractions if you are willing to wait a year or two more. Plutus is the core smart contract language of Cardano and it is based on Haskell programming language but obviously has a limited set of blockchain specific functionality instead of full compatibility.

As far as most existing projects I am extremely biased and have a hard time being objective. Suffice to say I do not believe very many real NFT have been minted as yet. There is nothing inherently wrong with verbatim copying Ethereum meta data formats or trying to capitalize on trending fads but there is also nothing exciting or interesting about this greed fueled frenzy.

We are only human …

2 Likes

Hi,
How many wallets do you all recommend in this pipeline?

Do you separate into 2 wallets:

  1. receiving ADA wallet from buyers
  2. mint and send it out

The reason is, I realized, if having only 1 wallet, some UTXO might get consumed (buyer paid) during the minting and sending out process.

I use two wallets. The first to receive payment, and the second is the purchasers wallet. When I receive a payment I take that UTXO and when minting the NFT split it up into two outputs. One output goes to the purchasers wallet with the NFT and minimum ada amount. The second output goes back to myself with the remaining ADA.

1 Like