0/5
_Follow along with this video! <3_ --- In this lesson, we will discuss important concepts ranging from transaction fees and gas prices, mining incentives, computational measures in transactions, to hands-on experience of sending a transaction in Ethereum’s test network. Let's jump right in! ### Transaction Fee and Gas Price: What are they? ::image{src='/blockchain-basics/06-intro-to-gas/intro-to-gas1.png' style='width: 100%; height: auto;' alt='etherscan transaction'} While inspecting an Ethereum transaction, two terms invariably catch the glance: "transaction fee" and "gas price". Let's clarify what they are and why they matter. The transaction fee is the amount rewarded to the block producer for processing the transaction. It is paid in Ether or GWei. The gas price, also defined in either Ether or GWei, is the cost per unit of gas specified for the transaction. The higher the gas price, the greater the chance of the transaction being included in a block. > Gas price is not to be confused with gas. While gas refers to the computational effort required to execute the transaction, gas price is the cost per unit of that effort. When we click on "more details" in a transaction overview, we can see further information including the `Gas Limit and Usage by transaction`. Now, let's address an important question: who gets these transaction fees and why? ### The Role of Nodes in Blockchain Blockchains are run by a group of different nodes, sometimes referred to as miners or validators, depending on the network. These miners get incentivized for running the blockchain by earning a fraction of the native blockchain currency for processing transactions. For instance, Ethereum miners get paid in Ether, while those in Polygon get rewarded in MATIC, the native token of Polygon. This remuneration encourages people to continue running these nodes. ### Understanding Gas in Transactions In the context of transactions, gas signifies a unit of computational complexity. The higher a transaction's complexity, the more gas it requires. For instance, common transactions like sending Ether are less complex and require relatively small amounts of gas. However, more sophisticated transactions like minting an NFT, deploying a smart contract, or depositing funds into a DeFi protocol, demand more gas due to their complexity. The total transaction fee can be calculated by multiplying the gas used with the gas price in Ether (not GWei). Therefore, `Transaction fee = gasPrice * gasUsed`. ### Hands-on: Sending an Ethereum Transaction In any blockchain, making a transaction requires the payment of a transaction fee (in terms of the native token) to the blockchain nodes processing that transaction. Let's take an example of a transaction using the MetaMask extension, a popular Ethereum wallet. Here are the steps: 1. Open MetaMask and click "Expand View". 2. Choose the account to use for the transaction. 3. Click on "Send". 4. Select "Transfer between my accounts". 5. Enter the account to send the Ether to, and the amount you wish to send. 6. Click "Next". MetaMask will automatically calculate the gas fee for you. The total amount to be paid is the sum of the Ether value you're sending and the gas fee. Something of note, if you click the `market` link in MetaMask, you'll be shown some optional settings for gas in the transaction. You may wonder _Why would I choose to spend more gas?_ A simplified explanation of this is: if lots of people are trying to process transactions at the same time, the space on a given block is competitive, gas prices are increased to throttle and prioritize transactions during congestion. 7. Click "Confirm". The transaction will now appear in the Activity tab of MetaMask. After a short while, the transaction gets processed, and you can view its details in a block explorer like Etherscan. You have now executed your first blockchain transaction! Despite its simplicity, knowing how to process transactions with MetaMask is vital and empowers you to interact with protocols on the Ethereum network and other blockchains. However, to fully understand Ethereum and the blockchain landscape, it's crucial to delve into the details behind these transactions and the fundamental mechanics of blockchains. Remember, mastering the nuances of blockchain transactions and understanding the mechanics behind Ethereum will enable you to become a powerful developer in the decentralized world. Next up, lets take a closer look at exactly how blockchains work.
Introduction to the concept of 'gas' in Ethereum, its role in transactions, and the mechanics of calculating transaction fees.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Blockchain fundamentals
Introduction to smart contract gas
Introduction to wallets
Transaction signatures
Smart contracts
Advanced gas concepts
Security researcher
$49,999 - $120,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on November 29, 2024
Solidity Developer
Blockchain BasicsDuration: 3h
Course Overview
About the course
Blockchain fundamentals
Introduction to smart contract gas
Introduction to wallets
Transaction signatures
Smart contracts
Advanced gas concepts
Security researcher
$49,999 - $120,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on November 29, 2024
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar