decrypt101
SocialOpen ProjectsSupport me My Resumes
  • Preface
    • Motivation
    • Roadmap’s
  • Introduction to Blockchain
    • A Brief History
    • Growth of Blockchain
    • Structure of Blockchain
    • Types of Blockchain
    • Key Technologies of Blockchain
    • Features of Blockchain
    • How Blockchain Works ?
    • Implementation of Blockchain
    • Summary
  • Components of Blockchain Architecture
    • Distributed Ledger
    • Blocks
    • Transaction
    • Chain
    • Peer-to-Peer Network
    • Blockchain Layers
    • Off-Chain & On-Chain
    • Wallet
    • Mining
    • Tokens
    • Assets
    • State Channels
    • Sidechains
    • Oracles on Blockchain
    • Atomic Swaps
    • Decentralized Identity (DID)
    • Blockchain Data Storage
    • Interoperability
    • Data structures for Scaling Blockchain
    • Maximal Extractable Value (MEV)
  • Consensus Mechanisms
    • Proof of Work (PoW)
      • Implemation Using Rust
    • Proof of Stake (PoS)
    • Proof of Burn (PoB)
    • Proof of Capacity (PoC)
    • Proof of Activity (PoAc)
    • Proof of Weight (PoWe)
    • Proof of Luck (PoL)
    • Proof of Ownership (PoO)
    • Proof of Existence (PoE)
    • Proof of Believability (PoBe)
    • Proof of History (PoH)
    • Proof of Authority (PoA)
    • Proof of Elapsed Time (PoET)
  • Cryptographics
    • Encryption & Decryption
      • Symmetric Encryption
      • Asymmetric Encryption
      • Key Management and Exchange
      • Implementation
    • Cryptographic Hashing
      • Secure Hash Algorithms (SHA)
      • Message Digest Algorithms
      • Ethash
      • Blake2
      • SCrypt
      • RIPEMD-160
    • Digital Signature
      • Digital Signature Algorithms
      • Digital Signature in Blockchain
    • Zero-Knowledge Proofs (ZKPs)
      • Types of Zero-Knowledge Proof and Protocols
      • A Case Study of Polygon Platform
    • Multi-Party Computation (MPC)
    • Cryptanalysis
    • Practical Implementation
  • Decentralized Application (DApp)
    • Design and UX in Web3
  • Smart Contract
    • Development Tools
    • Solidity
    • Testing Smart Contract
    • Developing Smart Contract
    • Interacting & Deploying with Smart Contract
    • Verifying Smart Contracts
    • Upgrading Smart Contracts
    • Securing Smart Contract
    • Smart Contract Composability
    • Testnet and Mainnet
    • Blockchain Platform Using Smart Contract
    • Application of Smart Contract
    • Practical Implementation
  • Blockchain Platforms
    • Ethereum
      • Ethereum Virtual Machine (EVM)
      • ETHER and GAS
      • Ethereum transaction
      • Ethereum Accounts
      • Ethereum Stacking
      • Ethereum Network
      • Ethereum Scaling Solutions
      • Ethereum Use-Cases
      • Getting Started with Ethereum
      • Ethereum Ecosystem and Support
    • Solana
      • Solana Architecture
        • Solana Account Model
        • Solana Wallet
        • Transactions and Instructions
        • Solana Programs
        • Program Derived Address (PDA)
        • Cross Program Invocation (CPI)
        • Tokens on Solana
        • Clusters and Public RPC Endpoints
        • Transaction Confirmation & Expiration
        • Retrying Transactions
        • Versioned Transactions
        • Address Lookup Tables
        • State Compression
        • Actions and Blinks
      • Solana Developments
      • Solana Client
      • Advanced Solana
      • Solana Scaling and Performance Architecture
      • Solana Solutions and cases
      • Practical Implemenation
    • Binance Smart Chain (BSC)
      • Create a BEP20 Token
    • Hyperledger Fabric
    • Cosmos
    • Polkadot
    • Quorum
    • Polygon
    • Algorand
    • Corda
    • Avalanche
    • TRON
    • Summary
  • Decentralized Finance (DeFi)
    • DeFi Components
    • DeFi Protocols
    • DeFi Platforms
    • DeFi Risk Classification
      • Infrastructure-layer Attacks
      • Smart Contract Layer-attacks
      • Application Layer-attacks
      • DeFi Risks
    • DeFi and Blockchain
    • DeFi Impact
  • Decentralized Ecosystem and Digital Innovation
    • Layer 2 Scaling Fundamental
    • Tokenomics
    • Cryptocurrency
    • Quantative Trading
    • NFTs
    • GameFi
    • Metaverse
  • Blockchain as a Service (BaaS)
    • Building Fullstack Blockchain Platform
    • Decentralized Digital Identity
    • Build a Cryptocurrencies Exchange
    • Play-to-Earn Gaming
    • Solana Token Airdrop Manager
    • Smart Contract Development on Solana with Rust
    • Quantitative Trading Platform
    • Insurances protocols
    • Flash Loans
    • Asset Management
    • Tokenized Derivatives
    • Automated Market Makers (AMMs)
    • Staking
    • Lending and Borrowing Platforms
    • Yield Farming
    • Stablecoin System
    • Security Token Offerings (STOs)
    • Initial Coin Offerings (ICOs)
    • On-Chain Voting Systems
    • Decentralized Autonomous Organizations (DAOs)
    • NFT Marketplaces
    • Provenance Verification
    • Supply Chain Tracking
    • Commodities Tokenization
    • Real Estate Tokenization
    • Digital Certificates
    • KYC (Know Your Customer)
  • Blockchain Development Across Languages
    • Blockchain using Go(Golang)
    • Blockchain using Rust
    • Blockchain using Python
    • Blockchain using Cairo
  • Distributed Systems & Infrastructure Technology
    • Classification of Distributed Systems
    • Networked systems versus Distributed systems
    • Parallel systems vs Distributed systems
    • Distributed versus Decentralized systems
    • Processes of Distributed Systems
    • Architecture of Distributed systems
    • Infrastructure Technologies
  • Distributed System Patterns
    • Distributed Agreements Algorithms
      • HoneyBadgerBFT
    • Data Replications
    • Data Partition
    • Consistency
    • Distributed Time
    • Cluster Management
    • Communication between Nodes
    • Fault Tolerance and Resilience
      • How to design better fault tolerance systems
      • Resilience Patterns
    • Coordination systems
      • Clock synchronization
    • Security
      • Trust in distributed systems
      • Design of Principal Security
      • Security threats, policies, and mechanisms
      • Authentication and Authorizations
      • Cryptography
      • Monitoring in Security
  • Distributed System Design
    • Page 1
    • Distributed Shared Memory
    • Distributed Data Management
    • Distributed Knowledge Management
    • Distributed Ledger
  • FAQs
  • Support and Community
Powered by GitBook
On this page
  • Transaction Creation and Signing Process
  • Types of Transactions
  • Transaction Status
  • Transaction Operations
  • Transaction Lifecycle
  • Understanding Ethereum Transaction Signing and Validation
  • The Role of Public-Key Cryptography
  • Delegating Private Key Management
  • Transaction Attributes: What Is Signed?
  • How Ethereum Validates Transactions
  • Security of Ethereum Transactions
  1. Blockchain Platforms
  2. Ethereum

Ethereum transaction

A transaction on an Ethereum blockchain is required to transfer ETH from EOA or for smart contracts to change state, perform an action, or read a state of a contract. A transaction can only be initiated from an EOA and it can further initiate other internal transactions.

For example, an EOA wallet initiates a transaction to call a function of contract A, and this contract calls another function of contract B. In this case, a transaction is initiated from an EOA to contract A and then an internal transaction is initiated from contract A to contract B.


Transaction Creation and Signing Process

A user begins by filling in the required fields to create a new transaction. Afterward, the transaction is signed using the private key associated with their Externally Owned Account (EOA). Once signed, the transaction is broadcast to the Ethereum blockchain via an Ethereum client. The client first verifies the transaction’s validity and ensures it is signed with the EOA’s private key, matching the address in the from field.

From

The from field contains the public address of the EOA that initiated the transaction. In Ethereum, only EOAs can initiate transactions, while contract accounts cannot. Transactions triggered by contracts are known as internal transactions (commonly referred to as "message calls" in Ethereum's yellow paper), which are triggered as a result of contract interactions.

To

The to field contains the public address of either an EOA or a smart contract. If the to address belongs to an EOA, the transaction is typically meant to transfer Ether (ETH). If it belongs to a contract, the transaction is either a function call to the contract or a transfer of ETH to the contract.

Value

The value field represents the amount of ETH being transferred in the transaction. For transactions between EOAs, this field is usually non-zero, indicating the amount of ETH being sent. In contract interactions, the value field can either be zero or non-zero, depending on the contract’s function.

Gas Limit

The gas limit is the maximum amount of computational effort (gas units) that the Ethereum Virtual Machine (EVM) is allowed to spend on the transaction’s execution.

Gas Price

The gas price is the amount of Ether that the user is willing to pay per unit of gas. It determines how much the user is paying to execute the transaction.

Nonce

The nonce is a counter that starts at 0 for every EOA and increments by 1 with each new transaction initiated by that account. It ensures transactions are executed in order and prevents replay attacks. When multiple transactions are pending, the one with the lowest nonce for that EOA is executed first.

Data

The data field contains the hexadecimal-encoded data required for invoking a smart contract method. When transferring ETH between EOAs, this field is empty (represented by 0x). However, when interacting with a contract, it contains the method signature and parameters in hexadecimal form.

For example, when calling the transfer() function on an ERC-20 token contract, the data field includes the method signature and the function's parameters. The hexadecimal code 0xa9059cbb represents the transfer() method, and the following bytes represent the parameters (recipient address and amount):

Types of Transactions

Let us tie the information we just learned about accounts with the different types of transactions:

  • Message call transaction: A message call derives from an externally owned account that wants to interact with another EOA or contract account. An example of a message call would be sending Ether from one account to another, or interacting with a smart contract (e.g, swapping tokens on Uniswap).

  • Contract creation transaction: A contract creation derives from an EOA to create a smart contract account (generally to store code and storage). An example of this type of transaction would be deploying a storage smart contract to store data.

Transaction Status

The transaction status lets the user know the status of a transaction. Transaction change or dropping a transaction is allowed in different states. A transaction can be in any of the following three statuses:

As shown in the preceding diagram, transactions are always initiated by an EOA. Let's go through each of the statuses.

Pending status

When a transaction is submitted to the Ethereum network, it first goes into the pending status, waiting to be executed by the nodes. A transaction can be in the pending state for a longer duration if the gas price is set very low in the transaction and the nodes are busy processing other higher gas price transactions. During the pending state, the transaction initiator is allowed to change the transaction fields at any time. They can do so by sending another transaction with the same nonce.

Success status

A transaction that is executed successfully without any failure is called a successful transaction. A successful transaction means the intended operation is executed successfully by the Ethereum blockchain and verified by other nodes present in the Ethereum blockchain network:

Fail status

A transaction is executed and, during the execution, it may fail due to an error in the contract method execution. Transaction failure also depends on the contract definition. Transaction execution failure could also occur in case of a low gas limit, and transactions will fail with the OutOfGasException error:

Dropped status

A transaction is sometimes dropped from the Ethereum network for several reasons:

  • If the transaction was in the pending state for a very long duration.

  • It has a very low gas price as compared to other pending transactions

  • The maximum number of pending transactions the Ethereum blockchain can handle are in the pending transaction pool

Once a transaction is dropped, all the gas and ETH is returned to the originating wallet:

Transaction Operations

There are two primary operations that can be performed on a transaction that has already been initiated, but remains in a pending status:

Replace/Update

If a user wants to modify certain fields of a pending transaction, they can do so by submitting a new transaction with the updated values while keeping the same nonce. This type of transaction is typically used when a transaction is pending due to a low gas price. By increasing the gas price in the new transaction (while keeping the nonce unchanged), the likelihood of the transaction being processed by the Ethereum network is increased, as miners prioritize transactions with higher gas fees.

Cancel

To cancel a pending transaction, the same EOA (Externally Owned Account) that initiated the original transaction can submit a new transaction with the same nonce. In this new transaction, the To field is set to the EOA’s own address, effectively sending a self-transaction with no impact other than canceling the pending one. The gas price for this new transaction must be higher than the original one to ensure that it gets processed first, allowing the user to override the pending transaction and prevent it from being executed. This is referred to as a self-transaction.

Transaction Lifecycle

The transaction lifecycle can be simplified to:

  1. An external account creates a transaction object.

  2. The account sending the transaction verifies it by signing which creates a transaction hash

  3. The transaction is broadcasted across the network using an Ethereum node

  4. The transaction execution is idle until the transaction is mined and added to the block or replaced/canceled.


Understanding Ethereum Transaction Signing and Validation

In the Ethereum blockchain, transactions are at the heart of how accounts interact, whether it’s transferring Ether or executing smart contracts. For these interactions to be secure and trustworthy, Ethereum uses public-key cryptography to ensure that only the owner of an account (Externally Owned Account or EOA) can authorize transactions from that account. This is accomplished by signing the transaction with a private key, which ensures that the signature was created by a specific private key holder and that the transaction can be verified.

The Role of Public-Key Cryptography

Public-key cryptography plays a vital role in securing Ethereum transactions. Here's a quick breakdown:

  • Private Key: A private key is the secret half of a key pair, used to sign transactions. This key must remain confidential because it grants control over the EOA.

  • Public Key: The public key is derived from the private key and is used to verify the authenticity of a transaction. The address of an EOA is a truncated hash of its public key, providing a unique identifier for the account.

When an Ethereum transaction is signed with the private key, anyone can use the public key (derived from the transaction’s address) to confirm that the signature is valid. This ensures that only the account owner can authorize transactions.

Why Private Keys Matter

  • Control of the Account: Knowing the private key of an EOA means that you have full control over that account and can sign transactions from it. This is why protecting private keys is crucial.

  • Signatures as Proof: The private key is used to generate a unique cryptographic signature for each transaction, proving that the transaction was authorized by the correct account holder. Without this signature, there’s no way for the network to authenticate the transaction.

Delegating Private Key Management

When developing smart contracts and decentralized applications (dApps), developers rarely deal with private keys directly. Managing private keys is sensitive and can lead to significant security risks if done improperly. Instead, developers use wallet software like MetaMask, which handles private key management and cryptographic signatures.

Wallets like MetaMask offer:

  • Security: By securely storing private keys.

  • Convenience: By handling transaction signing in the background.

  • Interfacing: They make it easy to interact with dApps, sign transactions, and access the Ethereum network without exposing the private key to the developer or the dApp.

Transaction Attributes: What Is Signed?

When a user initiates an Ethereum transaction, several key pieces of data are compiled and signed. Here are the core attributes included in the transaction and what they represent:

  1. Nonce

    • The nonce is a sequential number representing the count of transactions sent from a specific EOA. This ensures that transactions are processed in order and prevents duplicate transactions from being replayed.

  2. Gas Price

    • The gas price specifies the amount of wei (smallest unit of Ether) that the transaction will pay for each unit of gas consumed during execution. A higher gas price offers an incentive for miners to prioritize the transaction.

  3. Gas Limit

    • This represents the maximum amount of gas the transaction is allowed to consume. If the transaction exceeds this limit, it will fail, but the gas will still be spent.

  4. To Address

    • This is the recipient of the transaction. It could be the address of another EOA or a contract account. If deploying a new smart contract, the To field is left blank.

  5. Value

    • The amount of wei being transferred as part of the transaction. This can be zero in the case of contract calls or function executions.

  6. Data

    • This field holds additional data for the transaction. If the transaction is calling a function on a smart contract, the data field contains the function name and parameters. For contract deployment, this field stores the contract’s bytecode. In simple ETH transfers, this field is often left empty.

  7. Chain ID

    • Ethereum supports multiple networks, each with a unique identifier, called a chain ID. The Mainnet has a chain ID of 1, while testnets like Kovan use a different chain ID, such as 42. This ensures transactions are sent to the correct network.

How Ethereum Validates Transactions

Once the transaction attributes are concatenated and signed using the private key, the cryptographic signature is added to the transaction. The process works as follows:

  1. Transaction Signed by the Private Key: After creating the transaction, the user’s private key is used to generate a unique cryptographic signature that’s appended to the transaction.

  2. Broadcast to Ethereum Nodes: The signed transaction is broadcast to the Ethereum network, where nodes begin validating it.

  3. Signature Verification: Ethereum nodes use the sender's address (derived from the public key) to verify the transaction’s signature. This ensures that the transaction was actually authorized by the owner of the private key associated with the sending account.

  4. Rejection of Invalid Signatures: If the signature doesn’t match the public key or has been tampered with, the nodes reject the transaction, ensuring that unauthorized transactions do not enter the network.

Security of Ethereum Transactions

Ethereum’s transaction model is secure because:

  • Private Key Control: Only the owner of the private key can sign transactions, meaning unauthorized parties cannot move funds or execute actions on the account.

  • Signature Validation: Each transaction includes a signature that the network verifies before accepting the transaction. This ensures the authenticity of every interaction on the blockchain.

Using Web3 libraries, wallets, and cryptographic algorithms, Ethereum maintains the security and trustless nature of its decentralized system.

Understanding how Ethereum uses public-key cryptography, private keys, and signatures provides insight into the security of the blockchain. Developers are encouraged to use wallets like MetaMask to handle private key management securely. The signing process ensures that only the rightful owner of an account can authorize transactions, and Ethereum’s validation mechanism ensures the network only processes legitimate transactions. By properly securing private keys and leveraging wallet services, users and developers can safely interact with the Ethereum network.

PreviousETHER and GASNextEthereum Accounts

Last updated 8 months ago

This data can be decoded using tools like , which displays the function signature and its arguments.

The dropped transaction is not included in any block on the blockchain, as if it didn't happen or wasn't initiated. There is no trace of those transactions on the blockchain; you can only see these dropped transactions on (block explorer) for some time. Later, they may be removed from as they are not part of the blockchain. However, successful and failed transactions are included in the block of the Ethereum blockchain and their status can be checked from any blockchain client.

etherscan.io
etherscan.io
etherscan.io