Ethereum Transactions: Structure, Execution, and Storage

ยท

Understanding Ethereum Transaction Architecture

Ethereum transactions form the backbone of blockchain operations, enabling value transfers and smart contract interactions. Let's dissect their core components.

Transaction Structure Breakdown

1. Transaction Object Anatomy

Defined in core/types/transaction.go, the Transaction struct contains:

type Transaction struct {
    data txdata       // Core transaction data
    hash atomic.Value // Cryptographic hash cache
    size atomic.Value // Size measurement cache
    from atomic.Value // Sender address cache
}

Key elements:

2. txdata Composition

type txdata struct {
    AccountNonce uint64          // Transaction sequence number
    Price        *big.Int        // Gas price (wei)
    GasLimit     uint64          // Maximum gas allowance
    Recipient    *common.Address // Recipient address (nil for contract creation)
    Amount       *big.Int        // Ether value (wei)
    Payload      []byte          // Smart contract data
    V, R, S      *big.Int        // ECDSA signature components
    Hash         *common.Hash    // Transaction hash cache
}

Critical fields:

Transaction Types Demystified

1. Value Transfer Transactions

Basic ETH transfers between accounts:

2. Contract Creation Transactions

Deploys new smart contracts:

3. Contract Execution Transactions

Invokes existing contract methods:

๐Ÿ‘‰ Master Ethereum transaction types

Transaction Lifecycle

Creation Process

SendTxArgs struct (in internal/ethapi/api.go) defines submission parameters:

type SendTxArgs struct {
    From     common.Address  // Sender address
    To       *common.Address // Optional recipient
    Gas      *hexutil.Uint64 // Gas limit
    GasPrice *hexutil.Big    // Gas price
    Value    *hexutil.Big    // Ether amount
    Nonce    *hexutil.Uint64 // Sequence number
    Data     *hexutil.Bytes  // Contract payload
}

Execution Phases

Virtual Machine Externals

  1. Pre-Checks:

    • Nonce validation
    • Gas requirements verification
  2. Gas Handling:

    • Deduct gas costs from sender
    • Calculate intrinsic gas costs
  3. EVM Processing:

    • Contract creation (Create())
    • Method execution (Call())
  4. Post-Execution:

    • Gas refund calculations
    • Miner rewards distribution

Virtual Machine Internals

EVM processes:

Transaction Storage Mechanism

Database Operations

Storage Triggers

๐Ÿ‘‰ Explore Ethereum storage deep-dive

Frequently Asked Questions

What determines Ethereum transaction costs?

Transaction costs = GasUsed ร— GasPrice. GasUsed depends on computation complexity, while GasPrice reflects market demand.

Why are nonces important in transactions?

Nonces prevent:

How are contract creation transactions different?

They:

What's the maximum data size per transaction?

Ethereum enforces a 44KB data limit per transaction.

How are sender addresses verified?

Through ECDSA signature recovery from V, R, S components, converting the public key to an Ethereum address.

Why do transactions include gas limits?

To: