I’m working on a project where users can buy NFT bundles (anywhere from 1-10 tokens). Right now my process works like this: user buys a pack, my backend creates the NFTs, uploads them to IPFS, sends data to frontend, then user approves the mint transaction.
The problem is the generation step takes way too long. I’m thinking about switching to a queue based system instead. Users would join a queue on the smart contract first, then my backend service would poll this queue and handle both generation and minting automatically.
But here’s my issue - if I go with this approach, my service would need to cover all the gas costs for minting. Has anyone built something similar? What’s the best way to handle a blockchain queue system when you need to manage gas fees efficiently?
Hit this same issue 8 months back. Queue works great, but yeah - gas costs are brutal. Here’s what saved me: set up a credit system where users buy credits upfront covering both NFT price and gas estimates. Credits lock when they join the queue, unlock after minting. No more fronting gas from your pocket. Also check out EIP-2771 meta transactions if your contract supports them. Users sign off-chain, you relay the transaction, but they’re still paying gas through signature verification. For the queue itself, I combined smart contract events with Redis on the backend. Contract emits events when users join, my service processes them in order. Way more reliable than constantly polling contract state. Pro tip: build solid error handling for failed mints. Gas spikes kill transactions all the time, and you need a clean way to retry or refund users.
Hmm, interesting challenge! Need to know a few things first.
How long does generation actually take? 30 seconds per NFT or several minutes? That changes everything. What’s the bottleneck - image/metadata generation or IPFS uploads?
For gas fees, why not use a deposit system? Users deposit enough ETH upfront to cover estimated gas costs when they join the queue. Then you mint using their deposit instead of eating the costs yourself.
Or try a hybrid approach - pre-generate batches during low-traffic periods, then assign from that pool when users buy packs. Way faster than generating on-demand.
Also check out Gelato or OpenZeppelin Defender for automated minting. They handle queue management and gas optimization (though there’s fees).
What chain are you on? That affects your gas management options.
yeah, batch minting is def the way to go! costs way less than minting one by one. also, check out Layer 2 options like polygon or arbitrum; gas fees are super low there. also, meta transactions can help so users dont pay gas directly.