Member-only story
Hardcore Gas Savings in NFT Minting (Part 1)
(If you are seeing a paywall, read the store here). If you want to follow along, see this github repository: https://github.com/DonkeVerse/GasContest
Solidity is a very easy language to learn if the developer comes from a C-like language (Java, C, javascript, etc), but managing gas costs in the context of a blockchain is something that appears in very few other domains.
Let’s look at a typical workflow for a mint function in the gist below. A mint function is part of the blockchain backend to a web3 application where the user mints an NFT by clicking the mint button and agreeing to send a certain amount of cryptocurrency.
Here is a typical solidity workflow that mirrors various NFT smart contracts in production that has some very good features
This code was executed in a hardhat environment which reports the gas costs. The rest of the contract isn’t shown for brevity, but it inherits from OpenZeppelin’s ERC721Enumerable contract. If you wish to follow along, you can use the repository here as a starter.