Blockchain and Web3 course Β· Module 3: Ethereum & EVM

Ethereum - The Main Tunnel Network of the Crypt

3 min read Β·
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 ETH

EIP-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 pay

Ethereum 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. 1. What best describes Ethereum?

  2. 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

  1. QuestionWhat Is Ethereum?
  2. QuestionEVM - Ethereum Virtual Machine
  3. QuestionTypes of Accounts in Ethereum
  4. QuestionEOA vs Contract Account
  5. Coding taskEthereum Unit Conversions
  6. Put in orderOrder of Wei Units
  7. Click in orderStructure of an Ethereum Address
  8. Put in orderGas Components in Ethereum
  9. Coding taskCreating a Transaction Object
  10. QuestionGas and Fees
  11. QuestionGas Limit
  12. QuestionEIP-1559
  13. QuestionBase Fee vs Priority Fee
  14. Coding taskGas Calculator
  15. Put in orderThe Transaction Process
  16. Click in orderChain ID
  17. Put in orderEthereum Testnets
  18. Coding taskChecking an Account Balance
  19. QuestionTestnets
  20. QuestionEtherscan
  21. QuestionLayer 2 Solutions
  22. QuestionExamples of Layer 2
  23. Coding taskTransaction Simulator
  24. Put in orderBlock Structure
  25. Click in orderCreating a JSON-RPC Request
  26. Put in orderJSON-RPC Methods
  27. Coding taskComparing L2s
  28. QuestionNetwork Chain ID
  29. QuestionConverting Gwei to Wei
  30. QuestionConverting Ether to Wei
  31. Coding taskRPC Provider
  32. Put in orderEthereum Transaction Types
  33. Click in orderSigning a Transaction
  34. Coding taskSending a Transaction
  35. Put in orderNonce in Transactions
  36. Coding taskMonitoring a Transaction
  37. QuestionTransaction Receipt
  38. Coding taskBlock Explorer
  39. Put in orderBlock Finalization
  40. Click in orderDecode Transaction
  41. ConversationCongratulations! Ethereum Mastered
  42. Project to submitProject: Ethereum Dashboard