Ethereum is a decentralized, open-source blockchain platform that allows developers to build and deploy decentralized applications (dApps) and smart contracts.
The platform has a unique structure that consists of three main components.
- Ethereum Virtual Machine (EVM)
The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts on the Ethereum blockchain. It is a virtual machine that executes the bytecode of smart contracts and maintains the state of the blockchain. The EVM is responsible for verifying transactions, executing smart contracts, and maintaining the state of the blockchain.
- Ethereum Network
The Ethereum network is a decentralized network of nodes that run the Ethereum software. The network is responsible for maintaining the security and integrity of the blockchain by verifying transactions, mining blocks, and executing smart contracts. The Ethereum network uses a consensus mechanism called Proof of Work (PoW) to reach consensus on the state of the blockchain.
- Ethereum Client
An Ethereum client is software that allows users to interact with the Ethereum network. There are several different Ethereum clients available, including Geth, Parity, and OpenEthereum. Ethereum clients provide an interface for users to interact with the Ethereum network, including sending transactions, deploying smart contracts, and querying the blockchain.
In addition to these three main components, there are several other key aspects of the Ethereum structure, including the Ethereum Improvement Proposals (EIPs), which are proposals for changes to the Ethereum protocol; the Solidity programming language, which is used to write smart contracts for the Ethereum network; and the Ethereum Name Service (ENS), which is a decentralized domain name system for Ethereum addresses.
Overall, the Ethereum structure is designed to enable the creation and deployment of decentralized applications and smart contracts on a secure, decentralized blockchain network.
From now on, let’s look at Ethereum’s block structure and transaction structure.
Account
In Ethereum, an account is a digital entity that stores information and value on the Ethereum blockchain. There are two types of accounts: externally owned accounts (EOAs) and contract accounts (CAs).
Externally Owned Accounts (EOAs)
EOAs are the most common type of account in Ethereum. They are owned by individuals and controlled by private keys, which are used to sign transactions that send or receive Ether (the native cryptocurrency of the Ethereum network) and execute smart contracts. Each EOA has an associated balance, which represents the amount of Ether it currently holds.
Contract Accounts (CAs)
CAs are special accounts that are used to execute smart contracts on the Ethereum blockchain. They have a unique Ethereum address and are controlled by the code of the smart contract itself. CAs do not have an associated private key, and can only be accessed and modified through the execution of transactions.
State
The state of the Ethereum network represents the current state of all accounts and smart contracts on the blockchain. The state is updated through the execution of transactions that modify the values of accounts and smart contracts. The current state of the Ethereum network is stored in a database called the state trie.
Patricia Merkle Tree
The state trie is implemented using a data structure called a Patricia Merkle Tree. This data structure is used to efficiently store and update the state of the Ethereum network. A Patricia Merkle Tree is a type of Merkle Tree that is optimized for storing key-value pairs, where each key is a string and each value is the state of an account or smart contract.
Block Structure
An Ethereum block is a data structure that contains a list of transactions and other metadata. The structure of an Ethereum block includes the following components.
- Block Number: The number of the block in the blockchain.
- Timestamp: The time when the block was created.
- Nonce: A random value used in mining to generate a valid block hash.
- Difficulty: A value that represents how difficult it is to mine the block.
- Gas Limit: The maximum amount of gas that can be used in executing transactions in the block.
- Gas Used: The total amount of gas used in executing transactions in the block.
- Parent Hash: The hash of the previous block in the blockchain.
- Transactions: A list of transactions included in the block.
Block Header Structure
The block header is the part of the block that contains the metadata and is used to calculate the block hash. The block header structure includes the following components.
- Parent Hash: The hash of the previous block in the blockchain.
- Uncle Hash: The hash of the uncles included in the block.
- Coinbase: The address of the miner who created the block.
- State Root: The root hash of the state trie after executing transactions in the block.
- Transaction Root: The root hash of the Merkle tree of transactions in the block.
- Receipts Root: The root hash of the Merkle tree of transaction receipts in the block.
- Difficulty: A value that represents how difficult it is to mine the block.
- Gas Limit: The maximum amount of gas that can be used in executing transactions in the block.
- Timestamp: The time when the block was created.
- Extra Data: Arbitrary data that can be included in the block header.
Genesis Block
The Genesis block is the first block in the Ethereum blockchain. It was created by Ethereum’s founder, Vitalik Buterin, and was mined on July 30th, 2015. The Genesis block does not contain any transactions and has a unique block hash.
Uncle Block
An uncle block (also known as an “ommer block”) is a block that is not included in the main blockchain, but is still valid and can be included in the blockchain as a secondary block. Uncle blocks occur when two miners solve a block at approximately the same time, resulting in a temporary fork in the blockchain. Uncle blocks are included in the blockchain to incentivize miners to continue mining even if their block is not included in the main chain, and to increase the security of the blockchain by including additional blocks that attest to the validity of the main chain.
Transaction Structure
An Ethereum transaction is a message sent from one account to another, or to a smart contract. The transaction structure includes the following components.
- Nonce: A unique number used to prevent replay attacks.
- Gas Price: The price of gas in Ether that the sender is willing to pay for each unit of gas used in executing the transaction.
- Gas Limit: The maximum amount of gas that can be used in executing the transaction.
- To: The address of the recipient account or smart contract.
- Value: The amount of Ether being sent in the transaction.
- Data: Optional data to be included in the transaction.
EOA-EOA Transaction
An EOA-EOA (Externally Owned Account to Externally Owned Account) transaction is a transaction between two externally owned accounts. The sender signs the transaction with their private key, which is then used to verify the authenticity of the transaction.
EOA-CA Transaction
An EOA-CA (Externally Owned Account to Contract Account) transaction is a transaction between an externally owned account and a smart contract. The smart contract executes code in response to the transaction, and the result of the execution is stored in the blockchain.
Transaction Signature
Every transaction in Ethereum is signed by the sender’s private key to ensure the authenticity and integrity of the transaction. The signature is generated using the sender’s private key and is included in the transaction data.
Message Structure
In Ethereum, messages are similar to transactions, but are sent between smart contracts instead of between accounts. The message structure includes the same components as the transaction structure, but with additional fields for the sender and the code to be executed.
CA-CA Transaction
A CA-CA (Contract Account to Contract Account) transaction is a transaction between two smart contracts. The sender contract executes code in response to the transaction, and the result of the execution is stored in the blockchain.
Receipt Structure
After a transaction is executed, a receipt is created and stored in the blockchain. The receipt structure includes the following components:
- Transaction Hash: The hash of the transaction.
- Status: The status of the transaction (success or failure).
- Gas Used: The amount of gas used in executing the transaction.
- Contract Address: The address of the contract created by the transaction (if applicable).
Meta Transaction
A meta transaction is a type of transaction that is initiated and signed by a user, but executed by a relayer. The relayer pays the gas fees for the transaction and receives a fee from the user in return. Meta transactions are used to improve the user experience and reduce the complexity of using decentralized applications.
EIP-2770
EIP-2770 is a proposed Ethereum Improvement Proposal that defines a standard interface for meta transactions. The EIP aims to standardize the way that meta transactions are executed, making it easier for developers to build and integrate meta transaction functionality into their decentralized applications.
Conclusion
In summary, Ethereum uses a structure of accounts, blocks, and transactions to facilitate the storage and transfer of value and execution of smart contracts. The state of the network is stored in a Patricia Merkle Tree, and each block contains a list of transactions that are validated and executed as a single unit.