DeFi Basics
What Is a Smart Contract?
Learn what smart contracts are, how they work on blockchain networks, and why they are the foundation of DeFi applications like lending protocols and decentralized exchanges.
Learn what gas fees are in cryptocurrency, how they work on Ethereum and other blockchains, why gas fees fluctuate, and practical strategies for reducing transaction costs in DeFi.
If you have ever tried to make a transaction on Ethereum or another blockchain, you have encountered gas fees. They are the unavoidable cost of doing business on a decentralized network, and understanding how they work is essential for anyone participating in DeFi.
Gas fees are the transaction costs users pay to have their operations processed and validated by the blockchain network. The name comes from a useful analogy: just as a car needs gasoline to run, a blockchain transaction needs "gas" to execute. The more complex the operation, the more gas it requires.
For DeFi users, gas fees are a particularly important consideration. Simple token transfers are relatively cheap, but complex smart contract interactions, such as depositing collateral, borrowing stablecoins, or executing a liquidation, can consume significantly more gas. Understanding gas fees helps you make informed decisions about when, where, and how to execute your DeFi transactions.
Ethereum's gas system has three key components:
Gas units — A measure of computational effort. Each type of operation has a fixed gas cost. A simple addition costs 3 gas, storing a value costs 20,000 gas, and a standard ETH transfer costs 21,000 gas. Complex DeFi transactions can consume hundreds of thousands of gas units.
Gas price (in gwei) — The amount of ETH you are willing to pay per gas unit. One gwei is 0.000000001 ETH (one billionth of an ETH). Gas prices fluctuate based on network demand.
Gas limit — The maximum number of gas units you are willing to consume. This acts as a safety cap. If a transaction would exceed the gas limit, it fails and reverts, but you still pay for the gas consumed up to that point.
Your total transaction fee equals: Gas units used x Gas price per unit
For example, a simple token transfer using 21,000 gas at a gas price of 30 gwei costs: 21,000 x 30 gwei = 630,000 gwei = 0.00063 ETH.
In August 2021, Ethereum implemented EIP-1559, which fundamentally changed how gas fees work. Instead of a single gas price, transactions now have two components:
Base fee — A minimum fee per gas unit that is algorithmically set by the network. This fee is burned (destroyed) rather than paid to validators. The base fee increases when blocks are more than 50% full and decreases when they are less than 50% full.
Priority tip — An optional additional fee paid directly to validators to incentivize them to include your transaction sooner. During high-demand periods, a higher priority tip means faster inclusion.
This system made gas fees more predictable. Instead of blindly guessing a gas price, users can see the current base fee and decide how much of a priority tip to add based on their urgency.
Gas fees are fundamentally driven by supply and demand. Each Ethereum block has a target gas limit of roughly 15 million gas units (with a maximum of 30 million). This means there is a fixed supply of block space available per block, produced roughly every 12 seconds.
When demand for block space is high, users compete by offering higher priority tips. When demand is low, even minimal tips result in fast confirmation. This creates a fee market where prices can swing dramatically depending on network activity.
Several common scenarios cause gas fee spikes:
Gas fees tend to follow predictable daily patterns tied to when different regions are most active. Fees are typically highest during US and European business hours and lowest during Asian evening hours and weekends. Savvy DeFi users time non-urgent transactions accordingly.
Ethereum mainnet has historically had the highest gas fees in the crypto ecosystem because of its popularity and relatively limited throughput. A complex DeFi transaction can easily cost $10-50 during normal times and over $100 during peak congestion. This has made Ethereum mainnet increasingly the domain of larger transactions where the fee is a smaller percentage of the total value.
Layer 2 scaling solutions like Arbitrum, Optimism, and Base have been the most effective answer to Ethereum's high gas fees. These networks process transactions off the Ethereum mainnet while inheriting its security guarantees.
Gas fees on Layer 2 networks are typically 10-100x cheaper than Ethereum mainnet. A DeFi transaction that costs $30 on mainnet might cost $0.10-0.50 on Arbitrum. This dramatic reduction has made DeFi accessible to a much broader range of users and transaction sizes.
Borrow by Sats Terminal supports multiple chains, including Layer 2 networks, giving users the flexibility to choose lower-cost networks for their Bitcoin-backed borrowing.
Solana takes a different approach, with a fixed base fee of 5,000 lamports (approximately $0.001) per signature, plus priority fees during congestion. Solana's high throughput means that even during busy periods, fees rarely exceed a few cents. However, this low-fee model has its own trade-offs in terms of network architecture and decentralization.
Bitcoin uses a fee market based on transaction size in bytes rather than computational complexity. During busy periods, Bitcoin transaction fees can be substantial, but the introduction of the Lightning Network and other layer 2 solutions has provided lower-cost alternatives for smaller transactions.
Not all DeFi transactions cost the same amount of gas. Here is a rough hierarchy from least to most expensive:
Gas fees create a meaningful consideration for DeFi borrowers. If you are borrowing $500 worth of stablecoins against Bitcoin collateral, paying $30-50 in gas fees on Ethereum mainnet represents a 6-10% upfront cost. This is why smaller borrowers benefit significantly from using Layer 2 networks or alternative chains where gas fees are negligible relative to the loan amount.
Platforms like Borrow by Sats Terminal help address this by supporting lending protocols across multiple chains, so users can choose the network that offers the best combination of rates and transaction costs for their specific loan size. Borrow also collapses what would normally be a multi-step DeFi strategy — bridge, wrap, supply, borrow — into a single approval flow. The gas overhead is whatever the chosen chain requires, not the sum of every intermediate step you'd otherwise click through yourself.
One important gotcha for DeFi beginners: if your transaction fails (for example, due to insufficient gas limit, expired slippage tolerance, or a reverted smart contract call), you still pay for the gas consumed up to the point of failure. The blockchain's validators performed computational work to attempt your transaction, and they are compensated for that work regardless of the outcome.
This means setting appropriate gas limits and double-checking transaction parameters before confirming is important to avoid paying for failed transactions.
The single most effective strategy for reducing gas fees is to use Layer 2 networks. Arbitrum, Optimism, Base, and other L2s offer Ethereum's security with a fraction of the cost. Most major DeFi protocols now deploy on multiple L2s, and bridging assets to these networks is straightforward.
If your transaction is not time-sensitive, waiting for a period of lower network activity can save significant amounts on gas. Tools like Etherscan's gas tracker show current and historical gas prices, helping you identify optimal timing. Weekends and late-night hours (US time) typically offer lower fees.
Some protocols and wallets support transaction batching, where multiple operations are combined into a single transaction. This amortizes the base transaction cost across multiple actions, reducing the per-operation gas fee.
Not all protocols are equally gas-efficient. Some DeFi protocols have been specifically optimized for lower gas consumption through careful smart contract engineering. When comparing lending protocols on Borrow , gas costs are an additional factor worth considering alongside interest rates and liquidation thresholds.
Most wallets automatically estimate the gas limit for a transaction, but they often add a generous buffer. For standard operations, the wallet's estimate is usually fine. For complex DeFi transactions, it is worth checking that the gas limit is reasonable. Setting it too low causes the transaction to fail, and setting it too high does not cost extra (you only pay for gas actually used), but it can tie up funds temporarily.
Ethereum's EIP-4844 (implemented in early 2024) introduced "blob" transactions that dramatically reduced the data costs for Layer 2 networks. This made L2 gas fees even cheaper, often bringing DeFi transaction costs down to pennies. Further upgrades in Ethereum's roadmap aim to continue reducing costs.
Account abstraction (ERC-4337) enables new gas fee models, including the ability for protocols to pay gas fees on behalf of their users (gas sponsorship). This could eliminate the need for users to hold ETH for gas entirely, making DeFi more accessible to newcomers.
Some newer blockchains and Layer 2 networks are experimenting with alternative fee models, including fixed fees, subscription-based gas, and fee markets denominated in stablecoins. These innovations aim to make transaction costs more predictable and user-friendly.
Common Questions
Gas fees are the transaction costs users pay to execute operations on a blockchain network. On Ethereum, gas fees compensate validators for the computational resources needed to process and validate transactions. Every action on the blockchain, from a simple token transfer to a complex smart contract interaction like borrowing against collateral, requires gas. The fee amount depends on the complexity of the transaction and current network demand.
Related Questions
DeFi Basics
Learn what smart contracts are, how they work on blockchain networks, and why they are the foundation of DeFi applications like lending protocols and decentralized exchanges.
DeFi Basics
Learn what yield farming is in DeFi, how it works, the strategies involved, and the risks and rewards of farming crypto yields across decentralized protocols.
DeFi Basics
Learn what liquidity pools are in DeFi, how they work, why they matter for decentralized trading and lending, and the risks and rewards of providing liquidity.
DeFi Basics
Learn what decentralized finance (DeFi) is, how it works, and why it matters. Understand the core concepts of DeFi including smart contracts, blockchain, and permissionless financial services.