Sub topic 2
Ethereum: Accounts, the EVM, and Smart Contracts
This chapter assumes you know what a blockchain ledger is, what a hash is, and how public and private keys work at a high level. It also assumes you can read short Python snippets.
Ethereum keeps a single global state of accounts. Each account has a balance and a nonce, which counts the transactions the account has sent. There are two kinds. Externally owned accounts are controlled by private keys. Contract accounts hold code and storage, and they run only when a transaction or another contract calls them.
The Ethereum Virtual Machine (EVM) is the software that executes contract code on every node. Because each node runs the same code on the same inputs, they all reach the same result. A smart contract is a program stored at a contract account that runs this way.
Ether as Fuel: Gas, Base Fee, and Priority Fee
Every operation costs gas. A plain ether transfer uses 21,000 gas. The fee is gas used multiplied by the price per gas, which has two parts: a base fee and a priority fee (tip).
WEI_PER_GWEI = 10**9
WEI_PER_ETH = 10**18
gas_used = 21_000
base_fee_gwei = 20
priority_fee_gwei = 2
total_wei = gas_used * (base_fee_gwei + priority_fee_gwei) * WEI_PER_GWEI
print(total_wei / WEI_PER_ETH) # 0.000462 ETHIssuance and Fee Burning After the Merge
Since the Merge in September 2022, Ethereum uses proof of stake, and new ether issuance is much lower than before. The base fee is burned, which removes ether from supply. The priority fee goes to the validator who includes the transaction. When network use is high, burning can exceed issuance, and the supply shrinks.
Coins Versus Tokens
A coin runs on its own blockchain, as ether does on Ethereum. A token is a record in a smart contract on another chain. ERC-20 is the common Ethereum standard for fungible tokens, and it defines functions for balances and transfers.
A Map of Altcoins
- Smart contract platforms: chains that run general programs, such as Ethereum, Solana, and Cardano.
- Payments: coins built for fast, cheap transfers.
- Privacy: coins that hide sender, receiver, or amount.
- Exchange tokens: tokens tied to a trading venue, often offering fee discounts.
- Meme coins: tokens whose value rests mainly on community attention and carries little technical purpose.
> Categories overlap. A single asset can fit several of them.
Exercise
A transaction uses 50,000 gas with a base fee of 30 gwei and a priority fee of 1 gwei. How much ether does it cost in total?
Show answer
50,000 × 31 gwei = 1,550,000 gwei = 0.00155 ETH. The base fee part, 0.0015 ETH, is burned, and the tip, 0.00005 ETH, goes to the validator.