Long story short, it depends.
If you're jumping into Web3 development for the first time, exploring things like the Solidity programming language, Ethereum smart contracts, and making NFTs...
- Welcome! You're in for one heck of a ride..
- MAKE SURE YOU KNOW HOW GAS FEES AND TRANSACTION FEES WORK!
Back in the day.. deploying decentralized applications (DApps) was relatively affordable.
- In 2017, the CryptoPunks NFT project was deployed for $7.56 (source)
- In 2020, the Shiba Inu Token ($SHIB) was deployed for $60 (source)
Today — November 30th, 2021 — those exact same contracts would cost an arm and a leg to deploy :(
- CryptoPunks would cost $964
- $SHIB would cost $2,026
This means it costs you somewhere between 30x to 120x more in USD terms to deploy contracts to Ethereum today, compared to a few years ago.
The big question is... WHY?
Well, there are three things that ultimately affect your deploy costs:
- the UNITS of gas used in the transaction to deploy your contract
- the PRICE per gas based on current traffic conditions and network congestion
- the VALUE of Ether (ETH) based on market rates
and these factors come together in a very simple formula:
TOTAL COST = UNITS * PRICE * VALUE
Let's look at the CryptoPunks contract deployment from 2017 as a starting example. From looking at the transaction information on Etherscan:
- UNITS of gas = 2,142,276 gas
- PRICE per gas = 0.000000011 ETH per gas (or 11 gwei)
- VALUE of ETH = $320.97 per ETH
TOTAL COST = 2,142,276 * 0.000000011 * 320.97
TOTAL COST = $7.56
So what changes happen when we try to deploy the CryptoPunks contract today, in 2021?
- The UNITS of gas stayed the same — The # of gas units is dependent on the logic contained in the smart contract, and it's the same contract today as it was 4 years ago.
- The PRICE per gas has increased — Ethereum has become a very popular blockchain to transact on, and the more traffic there is, the more that a single unit of gas costs in ETH terms due to the gas bidding mechanism. This is when users send transactions with higher and higher gas fees included to incentivize miners to include their transactions first.
- The VALUE of ETH has also increased — More investors and interest over time means more demand for the cryptocurrency.
The average PRICE per gas these days is somewhere between 0.0000001 ETH - 0.00000015 ETH (100~150 gwei), while the average VALUE of ETH is somewhere between $4,000 ~ $4,500.
So how would the calculation look for deploying the CryptoPunks contract today?
- UNITS of gas = 2,142,276 gas
- PRICE per gas = 0.0000001 ETH per gas (or 100 gwei)
- VALUE of ETH = $4,500 per ETH
TOTAL COST = 2,142,276 * 0.0000001 * 4,500 = $964
Try it out yourself! Look up your favorite NFT contract on Etherscan, find the three components of the transaction fee, and verify the final cost. What kind of prices are you seeing today? Tweet your example @thatguyintech and I'd love to retweet :)
Now you might be thinking, "why are people still building on Ethereum if it's so expensive?"
That's an excellent question. And there are three very good reasons:
- Decentralization. Ethereum is the most decentralized smart contract platform available today. According to ethernodes.org, there are over 3000 nodes running the network. Other smart contract platforms have much fewer nodes or validators. The more decentralized the network is, the harder it is to censor, control, manipulate, or take down. These guarantees are usually necessary for serious financial applications.
- Developer Ecosystem. It has the largest developer ecosystem and most mature tooling. According to Electric Capital, Ethereum has over 2400 monthly active developers and growing. Ethereum is the oldest smart contract platform and has enjoyed the most network effects in terms of building usable applications and composable tooling.
- Market. Ethereum has the biggest market for DApps (most users and money). The largest and most used DeFi protocols and NFT marketplaces are built on Ethereum today.
Even with all these benefits however, this does not mean that Ethereum has to be the best tool for your project. Perhaps you are just poking around and learning and the cost of deploying to Ethereum mainnet does not make sense at all. Or maybe you're targeting a very specific use case that prioritize speed and efficiency over decentralization guarantees. Whatever it is, there are plenty of reasons why you might want to explore alternatives. Here are a couple of alternatives to get you started..
If you want to stay within the Ethereum ecosystem, check out sidechains and layer 2s (L2s):
The benefit of using a sidechain or an Ethereum layer 2 solution is that you can use similar tooling, and the underlying security mechanism for recording your transactions and securing your DApp remains the same. You also benefit from massively cheaper transaction costs and faster speed. The tradeoff is that both user and developer experience may be lacking for now.
If you want to venture farther and explore different blockchains with different programming languages and different system architectures, you should consider these other layer 1s (L1s):
Finally, if you are concerned about deployment costs but you still want to deploy on Ethereum mainnet, you can try optimizing your solidity code to reduce unnecessary logic. The purpose of gas fees is to pay miners for running the logic of your program. The less complex logic there is, the cheaper it is to deploy and run your contract.
Here's a great article that talks about how to optimize Ethereum NFT smart contracts to reduce gas: https://medium.com/@kaymonft/optimizing-nft-smart-contracts-to-reduce-gas-usage-7f4e819eb49d
If you found this explanation useful, shoot us a tweet at @AlchemyPlatform! We'd love to see what you're building and give your project a boost :)