DEV Community

Mhammed Talhaouy
Mhammed Talhaouy

Posted on

🔄 The Lifecycle of a Transaction — From Click to Confirmation

When you click “Send” on MetaMask or call a smart contract function, what actually happens behind the scenes?

Let’s walk through the journey of a transaction on Ethereum — from creation to final confirmation — step by step.


🧩 What Is a Transaction?

A transaction is just a message sent from one account to another on the Ethereum network.

It can:

  • Transfer ETH 💰
  • Interact with a smart contract ⚙️
  • Deploy a new contract 🧱

Every transaction changes the state of the blockchain — balances, storage, or data.


🚀 Step 1: Creating the Transaction

When you initiate a transaction in your wallet (e.g. MetaMask), you’re preparing these details:

Field Meaning Example
From Your address 0x123...
To Receiver address or contract 0xABC...
Value ETH amount to send 0.1 ETH
Data Encoded function call (optional) 0xa9059cbb...
Gas Limit Max gas you’ll allow 100,000
Max Fee / Gas Price How much ETH you’ll pay per gas unit 30 Gwei

Once you hit “Confirm,” your wallet:

  1. Estimates gas
  2. Signs the transaction using your private key 🔐
  3. Broadcasts it to the Ethereum network

🌐 Step 2: Broadcasting the Transaction

The signed transaction is sent to Ethereum nodes through your connected RPC (e.g. Infura, Alchemy, or your own node).

These nodes check:

  • Is the signature valid?
  • Does the sender have enough balance for gas + value?
  • Is the nonce correct (no duplicates)?

If valid ✅ → it goes into the mempool (short for memory pool).


🧮 Step 3: Waiting in the Mempool

Think of the mempool as a waiting room.
It holds all valid but unconfirmed transactions.

Miners (or validators in Proof of Stake) pick from this pool — usually starting with transactions offering higher fees.

So if you set a low gas price, your transaction may stay stuck in the mempool for a while ⏳.


⚙️ Step 4: Block Proposal (Mining / Validation)

Once a validator (in PoS) chooses your transaction, it becomes part of a block proposal.

In Proof of Stake:

  • Validators are randomly selected to propose the next block.
  • They include a set of transactions from the mempool.
  • Other validators then attest that the block is valid.

If approved → your transaction officially enters the blockchain!


🔗 Step 5: Execution by the EVM

Inside the block, the Ethereum Virtual Machine (EVM) executes your transaction.

It:

  1. Reads your transaction data
  2. Runs the contract code (if any)
  3. Calculates gas used
  4. Updates account balances and storage

If something fails (e.g., not enough gas or a revert), the transaction fails but still consumes gas for the work done.


✅ Step 6: Block Confirmation

Once your transaction is included in a block, it’s confirmed.

But to be extra safe, Ethereum waits for multiple confirmations (e.g. 12 blocks) before considering it final — because in rare cases, blocks can be reorganized.

Your wallet or blockchain explorer (like Etherscan) will show:

✅ “Transaction Confirmed in Block #XXXXXXX”


🔥 Step 7: Fee Burning (EIP-1559)

With EIP-1559, part of your transaction fee (the base fee) is burned — permanently removed from circulation — reducing ETH supply.

Only the tip (priority fee) goes to the validator as a reward.


📊 Summary: Transaction Lifecycle Overview

Step What Happens Who’s Involved
1️⃣ Create User signs the transaction Wallet
2️⃣ Broadcast Transaction sent to network RPC / Nodes
3️⃣ Mempool Waiting to be picked Network
4️⃣ Block Proposal Added to block Validator
5️⃣ Execution Code and state updated EVM
6️⃣ Confirmation Added to blockchain Validators
7️⃣ Finality Transaction irreversible Network

🧠 Example (Simple ETH Transfer)

  1. You send 1 ETH to a friend
  2. Wallet signs and sends transaction
  3. It enters the mempool
  4. Validator picks it and adds it to a block
  5. The EVM deducts 1 ETH from your balance and adds to your friend’s
  6. Transaction gets confirmed and visible on Etherscan

Done ✅ — simple as that, but under the hood, it’s a complex, elegant system keeping the network in sync.


🔍 For Auditors & Devs

As a smart contract auditor or dev, understanding this lifecycle helps you:

  • Trace how reverts and gas refunds happen
  • Understand nonce management
  • Analyze mempool-related exploits (like frontrunning or sandwich attacks)
  • Verify finality and replay safety

Top comments (0)