Before you read about Ethereum Transactions, please read about accounts in Ethereum here.
This article will focus on Ethereum transactions. We will read about Ethereum transactions-definition, types, attributes and lifecycle.
- transfer Ether to another account or a Smart Contract or,
- create a new account or,
- trigger a Smart contract to do some operation or,
- perform some operation in the EVM
Transactions are data packages which are cryptographically signed and which changes the state of the Ethereum blockchain network.
For example, if John sends 1 Ether to Elliot, then the account of John is debited by one Ether and that of Elliot is credited with one Ether. This changes the state of the Ethereum blockchain network.
Types of transactions in Ethereum
There are basically two types of transactions that can happen in Ethereum.
Normal or regular transactions: These are the normal transactions where Ether is transferred from one account to another account. See (in the figure below), it has a ‘From’ account address and a ‘To’ account address.
Contract deployment transactions– These are the transactions where the ‘To’ is the address of a Smart Contract. It looks something like the below. It also contains the code of the contract.
Attributes of an Ethereum Transaction
An Ethereum transaction has the following attributes:
- Recipient address: The account address where Ether has to be sent.
Remember, keeping this address vacant and attaching contract data in the transaction is the method to deploy a Smart Contract in the EVM. When you submit such a contract transaction, it will return a contract address so that you can access the contract in future.
- Signature: The signature identifies and verifies the sender. This is generated when the sender’s private key signs the transaction.
- Value: The amount of Ether, the sender is transferring to the receiver. This is denominated in wei (1 wei=10^-18 Ether).
- Data: Optional field to include arbitrary data.
- GasLimit: The maximum amount of gas units that can be consumed for processing the transaction.
Gas is a unit of work. Understand it as the unit of computational work which is needed to process a transaction. Each unit of Gas has a cost associated which is denoted in wei (1 wei=10^-18 Ether).The cost of Gas is determined by the current traffic of transactions in the EVM. More the traffic more is the cost of one unit of Gas.
Gas is required to counter the halting problem in EVM. Halting problem occurs when a malicious node by virtue of a loop or some malicious code tries to endlessly use the computational resources in EVM and hence halt other waiting transactions. Hence giving a maximum or upper limit of Gas stops the transaction after the number of computational steps specified by the Gas.
maxPriorityFeePerGas– the maximum amount of gas to be included as a tip to the miner
maxFeePerGas– the maximum amount of gas willing to be paid for the transaction (inclusive of
Lifecycle of a transaction in the Ethereum blockchain
- A user node submits a transaction in the EVM via a wallet.
- Cryptography converts the transaction into its corresponding hash value. Something like the below
- The hash of the transaction is included in a transaction pool and broadcast to the network.
- A miner must pick the transaction from the pool to include it in a Block to be verified and processed.
You may end up waiting at this stage until a miner picks up your transaction and include it in a Block.
- Once the transaction is processed by the EVM, you will receive a confirmation message. You will get a number of confirmations, which implies to the number of additional blocks created since the block which included your transaction. Higher the number of confirmations greater is the certainty that the network processed and recognized the transaction.
- If somehow your transaction failed, it might be due to a number of reasons. Please refer to this article to know more.
- If your transaction is stuck in pending status, please refer to our article here on how to cancel/replace the said transaction.
This article focused on Ethereum transactions-definition, types, attributes and lifecycle. We will know more about Ethereum transactions and Gas in the upcoming articles.