# Ethereum & Smart Contracts

> Programmable money and apps.

Module: Crypto — Deep Dive — Finotaur Academy (free lesson)
Source: https://www.finotaur.com/academy/crypto/ethereum-and-smart-contracts

## You'll be able to

Explain what Ethereum and smart contracts are, calculate a transaction fee from gas used, base fee and priority fee, and judge the specific risks that come with programmable money.

## In plain words

Ethereum is a public blockchain that runs smart contracts: programs stored on-chain that execute exactly as written whenever someone sends them a transaction, with every node verifying the result. Its native coin, ether (ETH), pays for the computation, measured in units called gas, and secures the network through proof of stake. Because contracts are code, they make lending, trading and token issuance possible without a company in the middle, but they also make bugs and permissions a direct source of financial risk.

```takeaways
- A **smart contract** is code at an address on the chain; anyone can call it, and its rules execute deterministically.
- Every operation costs **gas**; fee = **gas used × (base fee + priority fee)**, paid in ETH.
- Since August 2021 (EIP-1559) the **base fee is burned**; since the Merge in **September 2022** Ethereum runs on **proof of stake**.
- Tokens (ERC-20), NFTs (ERC-721) and DeFi all live inside contracts, so their safety depends on that code and on who can upgrade it.
```

## Real market example

**The Merge, September 2022.** Ethereum launched on 30 July 2015 using proof of work, like Bitcoin. On 15 September 2022 it switched consensus to proof of stake in an upgrade known as the Merge. Miners were replaced by validators who lock 32 ETH each, and new ETH issuance dropped sharply because validators are paid far less than miners were. Applications, balances and contract addresses did not change: the "engine" was swapped while the "car" kept moving.

Combine that with EIP-1559, which since the London upgrade in August 2021 burns the base fee of every transaction. When network demand is high, more ETH is burned than issued and total supply can shrink; when demand is low, supply grows slowly. ETH supply is therefore **variable**, unlike Bitcoin's fixed schedule.

**Fee arithmetic (hypothetical prices).** A simple ETH transfer uses exactly **21,000 gas**. Suppose the base fee is 20 gwei and you add a 2 gwei priority tip. One gwei is 0.000000001 ETH.

- Fee = 21,000 × (20 + 2) gwei = **462,000 gwei = 0.000462 ETH**.
- At a hypothetical ETH price of $3,000, that is **$1.39**.
- Of that, 21,000 × 20 = 420,000 gwei (0.00042 ETH) is **burned**; the 42,000 gwei tip goes to the validator.

A token swap might use 150,000 gas or more, so the same gas price would cost about seven times as much. Fees track demand for block space, not the size of your payment: moving $10 and $10 million costs the same gas.

```stats
21,000 | Gas for a plain ETH transfer | Fixed by the protocol
32 ETH | Stake per validator | Required to run one validator
12 s | Slot time | One block proposal opportunity per slot
1 gwei | = 0.000000001 ETH | The unit gas prices are quoted in
```

## Full explanation

### From ledger to world computer

Bitcoin's scripting language is intentionally limited. Ethereum's founders, led by Vitalik Buterin, designed a chain whose state includes not only balances but also programs and their storage. The **Ethereum Virtual Machine (EVM)** is the shared runtime: every node executes the same instructions on the same inputs and must arrive at the same result. Many other chains now run EVM-compatible environments, which is why the same wallet and contract code often work across several networks.

### Two kinds of accounts

- **Externally owned accounts (EOAs)** are controlled by a private key. They start every transaction.
- **Contract accounts** are controlled by code. They act only when called, and they can call other contracts.

A token balance is not stored "in your wallet". It is an entry in the token contract's storage mapping your address to a number. Your wallet simply reads it. This is why an **approval** (permission for a contract to move your tokens) is so powerful: you are authorising another contract to change that entry.

### Gas: why computation has a price

Without fees, anyone could post an infinite loop and freeze every node. Gas meters each operation; a transaction specifies a gas limit, and if execution runs out of gas it reverts, but the fee for the work done is still paid. Under EIP-1559 you set a **max fee** and a **max priority fee**; you pay the block's base fee plus your tip, and any difference up to your max is not charged. The base fee rises when blocks are more than half full and falls when they are less, by at most 12.5% per block.

### Proof of stake and staking yield

Validators earn rewards for proposing and attesting to blocks, plus priority fees and sometimes MEV (value extracted from ordering transactions). They can be slashed for provable misbehaviour. Liquid staking protocols let holders pool ETH and receive a tradable token representing the staked position. Staking yield is variable, depends on total ETH staked and on network activity, and carries smart-contract and slashing risk. Any figure you see is a snapshot, not a promise.

### Layer 2 rollups

Ethereum's base layer handles a limited number of transactions per second. **Rollups** execute transactions off the main chain and post compressed data and proofs back to Ethereum, inheriting much of its security at lower cost. Optimistic rollups assume transactions are valid unless challenged during a dispute window; zero-knowledge rollups post cryptographic validity proofs. Moving assets between a rollup and the main chain uses a bridge, which adds its own risk and sometimes a withdrawal delay.

### Smart contract risk, concretely

"Code is law" cuts both ways. In June 2016 a bug in The DAO, an early investment contract, let an attacker drain a large share of its ETH. The community responded with a hard fork that reversed the theft; those who rejected the fork kept the original chain, which continues as Ethereum Classic. The lesson persists:

- **Bugs** are executed faithfully. Audits reduce but do not eliminate them.
- **Admin keys and upgradeable proxies** mean a team or multisig can change contract logic. Check who holds them and whether changes are time-locked.
- **Oracles** feed external prices to contracts; manipulated or stale prices can trigger wrongful liquidations.
- **Composability** means one protocol's failure can cascade into others built on it.

### How traders use this knowledge

Professionals watch gas prices as a demand gauge, time large on-chain moves for quieter periods, check contract verification and admin permissions before depositing, and keep separate wallets for experimenting with new protocols. On the market side, ETH is often analysed through its fee burn, staking ratio and the share of activity moving to layer 2s, alongside the usual price and positioning data.

### Common mistakes

- **Approving unlimited token spending** to unknown contracts.
- **Setting a gas limit too low** to save money; the transaction fails and the fee is still lost.
- **Treating staking yield as risk-free interest.**
- **Bridging to a rollup or sidechain without checking withdrawal times and bridge security.**

```warning
Interacting with a smart contract can give it permission to move your tokens long after the transaction. Review approvals regularly and revoke the ones you no longer need. Never sign a transaction whose effect your wallet cannot clearly describe.
```

```checklist
title: Before interacting with an Ethereum contract
- Confirm the contract address from the project's official source, not a search ad or DM.
- Check that the source code is verified on a block explorer.
- Find out whether the contract is upgradeable and who controls upgrades.
- Read what your wallet says the transaction will do, including approvals.
- Limit approvals to the amount you intend to use.
- Use a separate wallet for new or unaudited protocols.
```

```quiz
[
  {
    "q": "A transaction uses 50,000 gas with a 30 gwei base fee and 2 gwei tip. What is the fee in ETH?",
    "options": ["0.0015 ETH", "0.0016 ETH", "0.016 ETH", "0.00016 ETH"],
    "answer": 1,
    "why": "50,000 × 32 gwei = 1,600,000 gwei = 0.0016 ETH."
  },
  {
    "q": "What happens to the base fee under EIP-1559?",
    "options": ["Paid to the validator", "Burned", "Sent to the Ethereum Foundation", "Refunded to the sender"],
    "answer": 1,
    "why": "The base fee is destroyed; only the priority fee goes to the block proposer."
  },
  {
    "q": "Where is your ERC-20 token balance actually recorded?",
    "options": ["Inside your hardware wallet", "In the token contract's storage", "On the exchange's server", "In your seed phrase"],
    "answer": 1,
    "why": "The token contract maps addresses to balances; your wallet holds the key that controls your address."
  },
  {
    "q": "What changed in the September 2022 Merge?",
    "options": ["ETH's supply was capped", "Ethereum moved from proof of work to proof of stake", "Gas was abolished", "All contracts had to be redeployed"],
    "answer": 1,
    "why": "The Merge replaced mining with staking-based consensus; balances and contracts were unchanged."
  }
]
```
