Blockchain Transactions
A blockchain transaction is a signed data package that transfers value or triggers contract logic between addresses. Understanding the anatomy of a transaction helps you debug failures and optimize costs.
Transaction Anatomy
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TRANSACTION STRUCTURE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ From: 0x742d35Cc6634C0532... โ
โ To: 0x9876543210abcdef... โ
โ Value: 1.5 ETH โ
โ Nonce: 42 (transaction count from โ
โ sender) โ
โ Gas Limit: 21000 (max gas allowed) โ
โ Gas Price: 20 gwei (cost per gas unit) โ
โ Data: 0x (empty for simple transfer) โ
โ Chain ID: 1 (Ethereum mainnet) โ
โ Signature: 0x8a3f... (proves ownership) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Transaction Lifecycle
1. User creates transaction in wallet
โ
โผ
2. Private key signs the transaction
โ
โผ
3. Signed transaction broadcast to network
โ
โผ
4. Nodes add it to the mempool (pending pool)
โ
โผ
5. Validator picks it up for inclusion
โ
โผ
6. Transaction is executed on-chain
โ
โผ
7. Block is finalized and confirmed
Gas โ Transaction Costs
Every operation on Ethereum costs gas. Gas protects the network from spam and compensates validators.
Gas Calculation:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Transaction Fee = Gas Used ร Gas Price โ
โ โ
โ Simple ETH Transfer: โ
โ Gas Used: 21,000 โ
โ Gas Price: 20 gwei โ
โ Fee: 21,000 ร 20 = 420,000 gwei โ
โ = 0.00042 ETH โ
โ โ
โ Complex Contract Call: โ
โ Gas Used: 150,000 โ
โ Gas Price: 30 gwei โ
โ Fee: 150,000 ร 30 = 4,500,000 gwei โ
โ = 0.0045 ETH โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Gas Limit: Maximum gas you're willing to spend. Unused gas is refunded.
Gas Price: How much you pay per unit of gas. Higher price = faster confirmation.
Transaction Confirmation
After a transaction is included in a block, it receives confirmations as more blocks are added. More confirmations mean greater certainty that the transaction is permanent and irreversible.