What is Ethereum?
Ethereum is a decentralized, open-source blockchain platform that enables developers to build and deploy smart contracts — self-executing programs that run exactly as programmed without downtime, censorship, or third-party interference. While Bitcoin was designed primarily as a digital currency, Ethereum was designed as a programmable blockchain — a "world computer" that can execute arbitrary code.
Ethereum vs Bitcoin
- Programmability: Ethereum supports Turing-complete smart contracts; Bitcoin has limited scripting capabilities
- Consensus: Ethereum uses Proof of Stake (since The Merge in September 2022); Bitcoin uses Proof of Work
- Block Time: Ethereum produces blocks every ~12 seconds; Bitcoin every ~10 minutes
- Native Currency: Ether (ETH) is used to pay for computation (gas); Bitcoin (BTC) is primarily a store of value
- Account Model: Ethereum uses an account-based model; Bitcoin uses UTXOs (Unspent Transaction Outputs)
The Ethereum Virtual Machine (EVM)
The EVM is the runtime environment for smart contracts on Ethereum. Every node in the Ethereum network runs an EVM instance, and all nodes execute the same code to reach consensus on the resulting state. The EVM is a stack-based virtual machine with its own instruction set (opcodes). Smart contracts written in Solidity or Vyper are compiled to EVM bytecode before deployment.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// A simple contract to illustrate EVM execution
contract Counter {
// State variable — stored in the contract's persistent storage
uint256 public count;
// Function to increment — modifies state, costs gas
function increment() external {
count += 1;
}
// View function — reads state only, free when called externally
function getCount() external view returns (uint256) {
return count;
}
// Pure function — no state access, purely computational
function add(uint256 a, uint256 b) external pure returns (uint256) {
return a + b;
}
}
Ethereum Accounts
Ethereum has two types of accounts, both of which can hold ETH and interact with the network:
Account Types
| Feature | Externally Owned (EOA) | Contract Account |
|---|---|---|
| Controlled by | Private key | Contract code |
| Has code | No | Yes |
| Can initiate txns | Yes | No (only respond) |
| Has storage | No | Yes |
| Creation cost | Free | Gas for deployment |
Gas and Transaction Fees
Every computation on Ethereum costs gas — a unit that measures the computational effort required to execute operations. Gas prevents infinite loops and resource abuse. Users pay gas fees in ETH. Since EIP-1559 (August 2021), Ethereum uses a base fee + priority tip model:
// Gas calculation after EIP-1559
interface TransactionFee {
baseFee: bigint; // Set by the protocol, burned
maxPriorityFee: bigint; // Tip to the validator
maxFeePerGas: bigint; // Maximum the user is willing to pay
gasUsed: bigint; // Actual computation units consumed
}
// Total fee = gasUsed * (baseFee + priorityFee)
// Example: 21,000 gas * (30 gwei + 2 gwei) = 672,000 gwei = 0.000672 ETH
// Common gas costs (approximate)
const gasCosts = {
ethTransfer: 21_000n, // Simple ETH transfer
erc20Transfer: 65_000n, // Token transfer
erc20Approve: 46_000n, // Token approval
contractDeploy: 500_000n, // Simple contract deployment
uniswapSwap: 150_000n, // DEX swap
nftMint: 120_000n, // Minting an NFT
};
Ethereum State and the World State Trie
Ethereum maintains a global state — a mapping of every account address to its state (balance, nonce, code hash, and storage root). This state is stored in a Modified Merkle Patricia Trie, enabling efficient lookups and cryptographic proofs. Every transaction modifies this state, and the state root hash is included in each block header.
Account State Fields
- Nonce: For EOAs, the number of transactions sent. For contracts, the number of contracts created. Prevents replay attacks.
- Balance: The amount of Wei (1 ETH = 10^18 Wei) held by the account.
- Code Hash: The hash of the EVM bytecode. For EOAs, this is the hash of an empty string. Contract code is immutable once deployed.
- Storage Root: The root hash of the account's storage trie. Only contract accounts have non-empty storage.
Ethereum Network Types
When developing, you will work with multiple Ethereum networks:
- Mainnet — the production Ethereum blockchain where real ETH has real value.
- Sepolia — a Proof-of-Stake testnet used for testing contracts with free test ETH.
- Holesky — another testnet focused on staking and infrastructure testing.
- Local networks — tools like Hardhat Network or Anvil (Foundry) run a local Ethereum node for fast, free testing during development.
Transactions on Ethereum
A transaction is a signed message from an EOA that modifies the Ethereum state. It includes the recipient address, the amount of ETH to send, optional call data (for interacting with contracts), gas limit, and fee parameters. Transactions are broadcast to the network, included in blocks by validators, and finalized through the consensus mechanism.
import { ethers } from 'ethers';
// Anatomy of an Ethereum transaction
const tx = {
to: '0xRecipientAddress...', // Target address (null for contract creation)
value: ethers.parseEther('1.0'), // Amount of ETH to send
data: '0x', // Calldata (empty for simple transfers)
gasLimit: 21000n, // Maximum gas units
maxFeePerGas: ethers.parseUnits('30', 'gwei'),
maxPriorityFeePerGas: ethers.parseUnits('2', 'gwei'),
nonce: 42, // Sender's transaction count
chainId: 1n, // Mainnet = 1, Sepolia = 11155111
type: 2, // EIP-1559 transaction type
};
// Signing and sending
const wallet = new ethers.Wallet(privateKey, provider);
const txResponse = await wallet.sendTransaction(tx);
const receipt = await txResponse.wait(); // Wait for confirmation
console.log('Block:', receipt.blockNumber);
console.log('Gas used:', receipt.gasUsed.toString());
The Merge and Proof of Stake
In September 2022, Ethereum transitioned from Proof of Work to Proof of Stake in an event called "The Merge." Validators now stake 32 ETH to participate in block production and attestation. This reduced Ethereum's energy consumption by approximately 99.95% while maintaining security. Validators are chosen pseudo-randomly to propose blocks, and other validators attest to the validity of proposed blocks. Malicious validators risk having their stake slashed.