To the end user, these fees seem like an extra charge, like a vague “service fee” on your hotel receipt. But these gas fees are an integral part of a functioning blockchain network. Without them, a user’s transactions won’t happen, and the entire system would grind to a halt.
What Are Gas Fees?
Gas fees are the costs users pay for executing an action on a blockchain network (actions like sending tokens or interacting with a smart contract). Every action has a computational and storage cost, and these fees, paid in the blockchain’s native currency, cover those costs and are paid to the miner that validates the transaction. Transaction fees are affected by multiple factors and can vary at different points in time, just like a household’s gas bill varies based on the amount of gas you consume for various activities like heating and cooking.
Why are they called “gas fees?” The term “gas fee” was originally specific to Ethereum’s transaction fees—Ethereum was the first smart contract network—but over time, the term “gas fee” has become a ubiquitous term for fees on any network, similar to the way you might hear someone ask for a “Kleenex®” when they mean tissue or “Chapstick®” when they mean lip balm.
The transaction fee might be called something else on another network, like "network fees," "miner fees," or simply "blockchain fees,” but whatever you call it, it’s a fee for the transaction.
Why do blockchain transactions charge a gas fee?
Transaction fees serve a few purposes in a blockchain network.
Miners (or stakers in a proof of stake blockchain network) are individuals (or companies) that validate and add transactions to the blockchain. To do this, they have to perform computational work, which costs electricity. These fees incentivize miners and stakers to participate in the network. Without an opportunity to profit, why would these actors support the network and validate pending transactions and package them into blocks?
It’s worth noting that miners and stakers also receive incentives from the blockchain protocol in itself through “coinbase” rewards, or “block rewards” - new emissions of the native cryptocurrency that are paid to miners with the successful mining of each new block.
However, in the case of Bitcoin, this reward is halved approximately every four years in an event called "halving," and the next Bitcoin halving will occur in the spring of 2024. With each halving, the fees miners earn from network activity become more critical to the longevity of the ecosystem.
Fees have the additional benefit of preventing spam on the network. By requiring users to pay a fee for every transaction, those gas fees prevent users from spamming the network with thousands of meaningless transactions, crippling the ecosystem and stopping legitimate participants from participating. With transaction fees as part of the network design, this type of behavior is economically irrational and unsustainable over time.
Why do gas fees fluctuate?
At a high level, transaction fees fluctuate because user demand fluctuates. The more transactions there are pending on the network, the higher fees go.
This is because blockchains have limited block space and are affected by the law of supply and demand. If user demand for that limited space increases, then the price goes up to meet that demand.
You can think of gas fees as somewhat like an auction of users bidding for that block space. If a user wants to outbid the competition and have their transaction validated first, they can simply pay a higher fee. This is similar to how surge pricing works in ride-share apps. During peak usage, the demand for a ride increases, and drivers prioritize rides that pay higher fees. If you aren’t willing to pay that high of a fee, you can wait until prices come down.
So transactions rise and fall to meet user demand, and in addition, users are able to specify what fee rate they want to pay (low, medium, or high), based on the priority of their transaction.
If a user has a high priority transaction, they can pay a higher fee to have that transaction processed by miners more quickly—miners will prioritize whichever transactions pay them the most fees.
When do you see spikes in block space demand and the highest fees? Popular NFT mints often trigger those spikes because users want to ensure they mint an NFT before the collection mints out—it’s a time sensitive transaction. For example, when Bored Ape Yacht Club creator Yuga Labs minted their Otherdeed NFTs, they sold each for 305 ApeCoin (approx. $5,800), but gas fees were as high as $14,000.
Fees also change in response to market conditions—in a bull market with increased network activity, average fees will be up—as well as to protocol changes. For example, the release of ordinals earlier in 2023 on Bitcoin led to more activity on the Bitcoin network, pushing average transaction fees higher.
How Are Transaction Fees Determined?
Gas fees can vary wildly across blockchain networks and at different times in a single network. Several factors influence the exact price, including:
- Transaction size/complexity: In Bitcoin, the primary cost factor is the size of the transaction in bytes. More complex transactions that include multiple inputs and outputs are larger and therefore cost more. This is different from Ethereum, Stacks, and other smart contract platforms, where the computational complexity of a transaction also determines its cost. For instance, a simple transfer of a token from one account to another requires less computational work than executing a complex smart contract.
- Block space demand: As we mentioned above, blockchains have limited space. That space varies by chain, but all blockchains have some upper bound on the maximum block size they can process. For example, Bitcoin has a maximum block size of 4M “weight units,” which translates in practice to around 2MB. When there is competition among users to get their transactions included in the next block, fees go up. When demand is low, fees go down.
- Priority: Users can also specify the priority of their transaction by picking a low, medium, or high fee. If a transaction isn't time-sensitive, users can choose to pay a lower fee, but they may have to wait longer for the transaction to be included in a block. If a transaction needs to be confirmed as soon as possible, users can choose to pay a higher fee to incentivize miners to include their transaction sooner.
Impact of Gas Fees on Users and Web3 Apps
Gas fees are an interesting facet of the user experience in Web3 apps. As a developer, you have no control over these fees. But they are integral to the blockchain, and you have to incorporate them into your application.
Blockchain clients and wallets typically calculate the fee automatically based on the current network conditions and the urgency of the transaction, so you don’t need to worry about that work. However, you should be mindful about how these fees can impact the user experience and adoption of your app.
- Cost to users: Gas fees directly affect your users: they have to pay for every action they take. Fees may make some in-app actions less economically rational for users, such as micro-transactions, and they may reduce user activity in your app.
- Inconsistent UX: What may cost a user a few cents one day may cost them several dollars the next. Fluctuation in gas fees creates an inconsistent UX, and that could cause frustration, particularly when that cost could come at the moment they want to use your app the most.
One way to mitigate the effect of uncontrollable gas fees is to incorporate gas estimation techniques in your app. By analyzing the complexity of the transaction, current network conditions, and anticipated resource consumption, users can get a more accurate estimate of the potential gas fees. This figure is usually provided by blockchain wallets and clients, but to the degree you can more clearly highlight that cost in your app, the better. You can also highlight the “gas limit” in your UX, which refers to the maximum fee a user could pay before the transaction aborts.
Each individual action has a cost to users, so you can also consider ways in which you can batch user actions into a single on-chain action in order to minimize the number of times a user incurs fees.
The choice of the underlying blockchain can also significantly influence the gas fees users have to pay. Some networks have lower average transaction fees than others, so selecting an appropriate blockchain to build your Web3 app can help keep transaction costs more manageable for your users. For example, Stacks’ current average transaction fee is 0.1mSTX, well under $0.01.
Choose the Blockchain Network With Reasonable Gas Fees
Mitigating high gas fees and their impact on Web3 apps is an ongoing focus for developers and the broader blockchain community. Developers and the blockchain community are exploring various initiatives, including gas optimization techniques, Bitcoin fee market improvement proposals, blockchain scaling solutions such as layer 2s, rollups, and more, all to reduce transaction costs.
Of course, there are other things to consider before choosing where to build your dApp beyond transaction fees. We wrote a developer’s guide to Web3 app development to fast-track your understanding of what goes into building a Web3 app. Inside you’ll find insights on various blockchain ecosystems, programming languages, dev tools, and more.