ETHEREUM BASICS EXPLAINED: ACCOUNTS, CONTRACTS, VALIDATORS & FEES
Understand Ethereum essentials including how accounts and validators work, the role of smart contracts, and how fees are calculated.
Ethereum is a decentralised blockchain platform that enables peer-to-peer transactions through smart contracts without relying on a central authority. A fundamental aspect of using Ethereum is understanding its core components. Let us begin with Ethereum accounts, which serve as digital identities on the network.
Types of Ethereum Accounts
There are two types of Ethereum accounts:
- Externally Owned Accounts (EOAs): Controlled by private keys, these accounts belong to individual users. They can initiate transactions and hold cryptocurrency.
- Contract Accounts: These are smart contracts deployed on the Ethereum blockchain. Unlike EOAs, they are not controlled by private keys but by the code stored on the blockchain. They only act when triggered by another transaction.
Account Structure
Each Ethereum account comprises the following variables:
- Nonce: Counter for the number of transactions sent from the account.
- Balance: The amount of ether (ETH) the account holds.
- Storage Root: The root hash of the Merkle Patricia trie that encodes the storage contents of the account (used mainly by contracts).
- Code Hash: The hash of the EVM code of the account (again specific to contracts).
Generating Ethereum Addresses
Ethereum addresses are derived from the public key of an externally owned account. Specifically, the process involves taking the last 20 bytes of the Keccak-256 hash of the public key, which produces a 40-character hexadecimal identifier. All interactions on the Ethereum network use these addresses.
Key Roles of Accounts
- Initiate and receive transactions
- Deploy and interact with smart contracts
- Hold and transfer ETH and ERC-20 tokens
It’s crucial to keep an account’s private key secure. Anyone with access to it can control the associated funds and permissions.
Public and Private Key Security
Ownership of an Ethereum account is established through key cryptography. The private key proves the identity of the account owner, while the public key allows others to verify signatures. Loss of a private key usually means permanent loss of access to funds.
Unlike traditional banking, there is no "forgot my password" option with Ethereum accounts. It's therefore vital to store keys and recovery phrases safely, often using hardware wallets for added protection.
One of Ethereum’s defining features is its ability to support smart contracts. These are self-executing code snippets that automatically enforce the terms of an agreement. Smart contracts revolutionise decentralised applications (dApps) by removing the need for middlemen.
What is a Smart Contract?
Smart contracts are programs stored on the Ethereum blockchain. Once deployed, they execute predetermined actions when specific conditions are met. Smart contracts operate deterministically which means that for a given input and state, they always produce the same output.
Programming Smart Contracts
Most Ethereum smart contracts are written in Solidity, a high-level programming language inspired by JavaScript and C++. Once written and tested, developers compile the smart contract into EVM-compatible bytecode, which is deployed to the blockchain.
Lifecycle of a Smart Contract
- Development: Code is written in Solidity and tested in development environments like Remix or Truffle.
- Deployment: The contract is deployed through a transaction. A new contract address is created upon success.
- Interaction: Users or other contracts interact with the deployed contract by sending transactions containing function calls and parameters.
Key Properties
- Immutable: Once deployed, the code of a smart contract cannot be changed. Updates require deploying a new version.
- Trustless: They eliminate the need to trust a central party or intermediary.
- Transparent: The code is publicly verifiable on the blockchain, meaning anyone can read and audit it.
Use Cases of Smart Contracts
- Decentralised Finance (DeFi): Enables lending, borrowing, and trading without intermediaries.
- Supply Chain Management: Tracks provenance and movement of goods transparently.
- Decentralised Voting: Ensures tamper-proof elections with instant results.
- Non-Fungible Tokens (NFTs): Governs the issuance and transfer of unique digital assets.
Smart Contract Limitations
Despite their potential, smart contracts have limitations:
- Bugs and Vulnerabilities: Poorly written contracts are susceptible to hacks, making security audits essential.
- Gas Costs: Each execution step requires gas; complex contracts can become expensive to interact with.
- Irreversibility: Once deployed, bug fixes or reversals must be handled through new deployments or auxiliary contracts.
In summary, smart contracts represent a powerful tool for automation and decentralised application logic, but they require careful design and scrutiny to be effective.
Ethereum transitioned from proof-of-work (PoW) to proof-of-stake (PoS) in September 2022, an event commonly known as The Merge. This upgrade fundamentally changed how Ethereum secures its network and processes transactions, replacing miners with validators.
The Role of Validators
Validators are users who lock up ETH (a process called staking) to gain the right to propose and validate new blocks. The minimum stake required is 32 ETH, though smaller amounts can be used through staking pools.
Validators are randomly selected to propose new blocks and confirm those proposed by others. They must remain online and act honestly; otherwise, they risk having a portion of their staked ETH "slashed" as a penalty.
Transaction Fees and Gas
On Ethereum, transaction fees are calculated using a unit called gas. Every operation on the Ethereum network—whether sending ETH, transferring tokens, or interacting with a smart contract—consumes gas.
The total fee paid by a user is:
Total Fee = Gas Units Used × Gas Price
- Gas Limit: The maximum amount of gas a user is willing to use for a transaction.
- Gas Price: The amount of ETH (in gwei) a user is willing to pay per unit of gas.
The EIP-1559 Upgrade
Introduced in August 2021, EIP-1559 overhauled Ethereum’s fee mechanism. It introduced:
- Base Fee: A non-negotiable fee, burned and removed from circulation.
- Priority Fee (Tip): An optional payment to incentivise validators to prioritise a user's transaction.
This makes gas fees more predictable, and burning the base fee contributes to ETH's deflationary pressure.
How Fees Affect Users
Users must pay gas fees whether transferring ETH or executing a function in a smart contract. More complex operations cost more gas. When the network is congested, gas prices surge due to bidding competition for prompt inclusion in blocks.
Reducing Transaction Costs
There are several strategies for reducing or mitigating transaction costs:
- Timing: Avoid trading during peak hours when demand for block space is high.
- Layer 2 Solutions: Platforms like Arbitrum, Optimism, and zkSync offer significantly reduced fees by processing transactions off-chain and posting compressed data to Ethereum.
- Batching: Combine multiple transactions into one when possible.
Post-Merge Rewards for Validators
Validators are rewarded for adding blocks to the blockchain and attesting to others. Their rewards include:
- Base rewards, paid directly for performing duties
- MEV (Miner Extractable Value), now relayed to validators via new infrastructure
- Priority fees and tips from users
Ethereum's shift to PoS has proven more environmentally sustainable while enhancing security and scalability pathways. The future lies in continual upgrades like Shard Chains and Danksharding to handle higher throughput with lower fees.