Alpha Girl Club Innovates with Low Gas Optimization
Everyone hates gas. We’ve lowered it, big time.
Alpha Girl Club is tackling the NFT space to be a beacon for all individuals who struggle from finding their inner Alpha. To be an Alpha means to face your most daring demons and fears, show kindness and respect towards others altogether, Alpha or not, and to stand up for others when they cannot stand up for themselves. Alongside the uniqueness of the art, they are fighting for self-empowerment and mental health, and believe it is time for the NFT community to join hands with real-world communities, to fight for these social changes together.
Alpha Girl Club (AGC) officially begins their mint sale this weekend on Saturday 12/4 for people on the whitelist, and Sunday 12/5 for the public.
The worst thing about buying NFT’s on the Ethereum network are the gas fees. The team at Alpha Girl Club wanted to make sure their members had the opportunity to mint peacefully without worrying about gas wars — getting by the typical roadblocks of expensive whitelist storage and other on-chain issues. Their latest addition is their low contract optimization in the AGC Smart Contract. Working up till launch week, they fired minting the first Alpha (purposely ID’ed at 0 and not to be sold) on the mainnet during the typical heavy minting and release of other big projects.
Put to the test, the mint was done at a 120–200 gas range using the fastest typical recommended gas settings. Although the option to have gone lower at the typical 100 gas and had it arrive in around 30 seconds, they wanted to simulate the most intense launch day situation. So what were the results?
The transaction at ~130 Gwei was only $55 USD approximately, a record low gas fee at such a high gas level, in comparison to projects launching with thousands in gas fees. At 100 Gwei in another test this would be around $40-$45. Now imagine the gas fee at the occasional 70–90 mark. Low right?
Typically, this required some programming tricks and optimization. Here’s a brief technical summary on how this was done:
This is the link to Alpha Girl Club’s official contract code if you want to see these concepts visually.
Firstly, the contract does not make any use of the typical Enumerable functions of most ERC721 NFT’s. Enumerable has some use in getting values such as the balance and iterating over such counts, hence the name “Enumerating”. From the official documentation. the enumeration extension is optional for ERC-721 smart contracts (see “caveats”, below). This allows your contract to publish its full list of NFTs and make them discoverable. The fact that the team removed this is indicated by the warning shown on Etherscan here. It’s harmless.
Many projects just go ahead and include enumerable, not realizing that its negatives might outweigh the positives, depending on their use case. Many devs and project owners are clueless about this optimization, sadly, and only recently have OpenZepplin modifications really been pursued. Alpha Girl Club’s used case had no need for these gas heavy enumerations, and they opted to strip out enumeration functions.
Several tricks can be done in the future if total owner counts are needed, such as getting the owner of every token and adding them up programmatically to simulate the same effect. Here is an example of this on the frontend (Credit to WGMIO and Squeebo).
Beyond this, the contract’s code is super optimized and removes any heavy whitelisting system, opting instead for hashing checks handled off-chain. They are able to see this in the minting function that first receives a hash from an external Cloudflare server and checks to see if the user exists in a whitelisting database. This approach was first pioneered by the SVS team so credit to them for being daring adventurers
If you want to get started with gas optimization in this style, start exploring smart contracts like Alpha Girl Club’s, along with setting up a good Hardhat environment with the gas plugin for testing.