Blockchain and Web3 course Β· Module 3: Ethereum & EVM
Ethereum - The Main Tunnel Network of the Crypt
In this lesson6
Welcome to the Main Tunnels! Atlas here. Today you'll get to know Ethereum - the most powerful tunnel network in the entire Crypt, where smart contracts and decentralized applications operate.
What is Ethereum?
Ethereum is more than a cryptocurrency - it's a decentralized world computer. Imagine a vast network of tunnels where each chamber can contain not only transactions but also automated mechanisms (smart contracts).
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ETHEREUM WORLD COMPUTER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β EVM (Machine) β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ β β
β β β Smart β β Smart β β Smart β β β
β β β Contract 1 β β Contract 2 β β Contract 3 β β β
β β βββββββββββββββ βββββββββββββββ βββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β STATE (Network State) β β
β β β’ Account balances β β
β β β’ Contract code β β
β β β’ Contract storage β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββEVM - Ethereum Virtual Machine
The EVM is the "engine" that executes smart contract code. It works identically on every node:
EVM Properties:
- Deterministic - same code = same result
- Isolated - contracts cannot affect the system
- Turing-complete - can perform any computation
- Stack-based - uses a stack for operations
Account Types in Ethereum
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ACCOUNT TYPES β
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ€
β EOA (Externally β CONTRACT ACCOUNT β
β Owned Account) β β
βββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ€
β Controlled by β Controlled by code β
β a private key β β
β Can hold ETH β Can hold ETH β
β Can send TX β Reacts to TX β
β Has a private key β Has no private key β
β Can initiate TX β Cannot initiate TX β
βββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββGas - Energy in the Tunnels
Gas is a computational unit - "fuel" for transactions:
Transaction cost = Gas Used Γ Gas Price
Example:
- ETH Transfer: ~21,000 gas
- Swap on Uniswap: ~150,000 gas
- Contract Deploy: ~1,000,000+ gas
At Gas Price = 30 gwei:
- Transfer: 21,000 Γ 30 gwei = 630,000 gwei = 0.00063 ETHEIP-1559 - New fee model:
Transaction Fee = (Base Fee + Priority Fee) Γ Gas Used
β’ Base Fee - burned, changes dynamically
β’ Priority Fee - for the validator (tip)
β’ Max Fee - the maximum amount you'll payEthereum Networks
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ETHEREUM NETWORKS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β MAINNET (Chain ID: 1) β
β βββ Real ETH, production β
β β
β TESTNETS: β
β βββ Sepolia (Chain ID: 11155111) - main testnet β
β βββ Hoodi (Chain ID: 560048) - validator testnet β
β β
β LAYER 2: β
β βββ Arbitrum (Chain ID: 42161) β
β βββ Optimism (Chain ID: 10) β
β βββ Base (Chain ID: 8453) β
β βββ Polygon (Chain ID: 137) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSummary
- Ethereum = decentralized world computer
- EVM executes smart contracts
- EOA vs Contract Account
- Gas - computational unit
- EIP-1559 - base fee + priority fee
- Mainnet, Testnets, Layer 2
Code for this lesson: index.js
// Ethereum transaction structure
const transaction = {
// Sender address (recovered from signature)
from: "0x742d35Cc6634C0532925a3b844Bc9e7595f1dE3a",
// Recipient address
to: "0x8ba1f109551bD432803012645Ac136ddd64DBA72",
// Value in wei (1 ETH = 10^18 wei)
value: "1000000000000000000", // 1 ETH
// Data (for smart contracts)
data: "0x",
// Gas
gasLimit: 21000, // Gas unit limit
maxFeePerGas: "50000000000", // 50 Gwei
maxPriorityFeePerGas: "2000000000", // 2 Gwei
// Nonce - transaction counter
nonce: 42,
// Chain ID (1 = mainnet, 11155111 = Sepolia)
chainId: 1,
// Transaction type (2 = EIP-1559)
type: 2
};
console.log("=== ETHEREUM TRANSACTION STRUCTURE ===\n");
// Conversions
const ethValue = Number(transaction.value) / 1e18;
const gweiMaxFee = Number(transaction.maxFeePerGas) / 1e9;
const maxCostWei = transaction.gasLimit * Number(transaction.maxFeePerGas);
const maxCostEth = maxCostWei / 1e18;
console.log("From:", transaction.from);
console.log("To:", transaction.to);
console.log("Value:", ethValue, "ETH");
console.log("\nGas:");
console.log(" Limit:", transaction.gasLimit.toLocaleString(), "units");
console.log(" Max fee:", gweiMaxFee, "Gwei");
console.log(" Max tx cost:", maxCostEth.toFixed(6), "ETH");
console.log("\nNonce:", transaction.nonce);
console.log("Chain ID:", transaction.chainId, "(Ethereum Mainnet)");
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What best describes Ethereum?
2. What is the EVM (Ethereum Virtual Machine)?
These are 2 of 16 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Code editor
Implement functions to convert between Wei, Gwei, and Ether
- Vertical ordering
Arrange the Ethereum units from smallest to largest:
- Click in order
Click the elements in order to form a valid Ethereum address (40 hex characters + prefix)
- Horizontal ordering
How do we calculate the maximum transaction cost in the EIP-1559 model?
- Code editor
Implement a transaction structure with the fields: from, to, value, gasLimit, maxFeePerGas, maxPriorityFeePerGas
- Code editor
Implement calculateTransactionCost(gasLimit, gasPrice) that returns the cost in Wei and Ether
- Vertical ordering
Arrange the steps of executing an Ethereum transaction in the correct order:
- Click in order
Click in the correct order to show the Chain ID for Ethereum Mainnet
- Horizontal ordering
Which testnet is currently mainly supported by the Ethereum Foundation?
- Code editor
Create a getBalance(address) function that uses a provider to fetch the balance and convert it from Wei to Ether
- Code editor
Implement a simulateTransaction(from, to, amount, balance) function that checks whether a transaction is possible
- Vertical ordering
Arrange the main components of an Ethereum block in logical order:
- Click in order
Click the elements in order to form a valid JSON-RPC request
- Horizontal ordering
Which JSON-RPC method is used to fetch an account's balance?
- Code editor
Implement a data structure that stores information about L2s: Arbitrum, Optimism, Base (Chain ID, type, features)
- Code editor
Implement setupProvider(rpcUrl) that creates a JsonRpcProvider and tests the connection with the getBlockNumber() method
- Vertical ordering
Arrange the Ethereum transaction types according to their chronological evolution:
- Click in order
Click in the correct order to show how to sign a transaction in ethers.js
- Code editor
Implement sendEther(wallet, toAddress, amountInEther) that creates, signs, and sends a transaction
- Horizontal ordering
How do you get the nonce for an address before sending a transaction?
- Code editor
Implement waitForTransaction(txHash, confirmations) that waits for a specified number of confirmations
- Code editor
Implement getEtherscanLink(address, chainId, type) where type is 'address', 'tx', or 'block'
- Vertical ordering
Arrange the stages of transaction confirmation in Ethereum:
- Click in order
Click in the correct order to show how to decode a raw transaction
Tasks after this lesson
- QuestionWhat Is Ethereum?
- QuestionEVM - Ethereum Virtual Machine
- QuestionTypes of Accounts in Ethereum
- QuestionEOA vs Contract Account
- Coding taskEthereum Unit Conversions
- Put in orderOrder of Wei Units
- Click in orderStructure of an Ethereum Address
- Put in orderGas Components in Ethereum
- Coding taskCreating a Transaction Object
- QuestionGas and Fees
- QuestionGas Limit
- QuestionEIP-1559
- QuestionBase Fee vs Priority Fee
- Coding taskGas Calculator
- Put in orderThe Transaction Process
- Click in orderChain ID
- Put in orderEthereum Testnets
- Coding taskChecking an Account Balance
- QuestionTestnets
- QuestionEtherscan
- QuestionLayer 2 Solutions
- QuestionExamples of Layer 2
- Coding taskTransaction Simulator
- Put in orderBlock Structure
- Click in orderCreating a JSON-RPC Request
- Put in orderJSON-RPC Methods
- Coding taskComparing L2s
- QuestionNetwork Chain ID
- QuestionConverting Gwei to Wei
- QuestionConverting Ether to Wei
- Coding taskRPC Provider
- Put in orderEthereum Transaction Types
- Click in orderSigning a Transaction
- Coding taskSending a Transaction
- Put in orderNonce in Transactions
- Coding taskMonitoring a Transaction
- QuestionTransaction Receipt
- Coding taskBlock Explorer
- Put in orderBlock Finalization
- Click in orderDecode Transaction
- ConversationCongratulations! Ethereum Mastered
- Project to submitProject: Ethereum Dashboard