👉 Miners use their computational resources—mostly time and memory—to execute smart contracts. The user that wants to execute that contract pays a “transaction fee” to the miner in exchange for their computational resources.
👉 The amount of the transaction fee can vary depending on the complexity of the transaction. A complex smart contract with many operations consumes more computational resources, so it requires a higher transaction fee.
👉 Transaction fees help with two things:
- Incentivizing miners. It helps to ensure that a blockchain remains decentralized by incentivizing miners to get paid and participate in the network.
- Preventing spam and abuse. Requiring a fee to run the code deters spam accounts from sending too many transactions to the network.
🧠 Reminder: The Bitcoin network incentivizes miners by letting them create new bitcoins and transfer them to their own accounts. The goal here is similar. But this time, the user that wants to run the code has to pay the fee, which is in the form of the blockchain's native cryptocurrency.
💅 Fun fact: The transaction fee is called different things for different blockchains. Ethereum and Cosmos use the label of “gas fee” while Solana calls it “rent.”