#80: Ethereum: a distributed virtual machine for exchanging money and bored apes
Ethereum is a network of computers with no central trusted authority. They achieve consensus by running computation-intensive algorithm, known as proof-of-work. The agreed state is added to an append only ledger, known as blockchain. Yes, Ethereum is yet another blockchain. And it’s used to track transactions in a cryptocurrency, known as Ether. However, unlike Bitcoin, it’s much more than a simple log. Bitcoin accounts simply hold currency. Ethereum accounts can run programs as well. Ethereum network is actually one, huge computer!
I already talked about blockchain in episodes 26 and 27. Let’s explore what makes Ethereum unique. At its core, Ethereum is an ever-growing ledger of transactions. By going through these transactions we can figure out how much Ether each account owns. However, there are also special accounts, known as smart contracts.
Smart contract is an application written in dedicated programming language. This program runs inside Ethereum network. The outcome of such a program is typically some financial operation. Other use cases include crowdfunding, multi-signatures, tracking ownership of any goods, etc. Smart contracts can deploy and run other contracts.
Let’s dive a little bit deeper. When you write such a contract, you use high-level language like Solidity. This language is then compiled into bytecode. Similar to Java or .NET. Then you must publish your contract. The contract becomes public part of the blockchain. Forever. And for a small fee.
Talking about fees… Your smart contract is then run on each and every computer in the Ethereum network. It receives current state of the blockchain as input. The state represents balance of every account. Smart contract runs and produces new state. The new state becomes input to subsequent smart contracts.
So essentially Ethereum is a giant state machine. Known as Ethereum Virtual Machine. EVM for short. This has a potential for abuse. Notice that EVM runs the same code hundreds of thousands of times. And it’s single-threaded.
So every possible bytecode operation has a tiny cost. Known as gas. Some operations are orders of magnitude more expensive than the others. For example, storing something onto blockchain costs you much more than an arithmetic addition. This algorithm prevents programs from running forever or doing something too complex.
This unusual design has one advantage. You don’t need one, trusted server to run your contracts. Instead, all machines run all contracts. One bad actor cannot manipulate the outcome of the program. The rest of the network would immediately notice.
Of course, there are disadvantages. EVM is effectively single-threaded. Also, the amount of redundant work is astounding. No wonder why Ethereum can currently run just 15 transactions per second. The big Ethereum 2.0 upgrade may increase that limit to tens of thousands per second. So almost, almost as much as an old-school credit card company. The good news is that 2.0 will switch from proof-of-work to proof-of-stake algorithm. Much less energy consuming.
Technically, you can run all sorts of contracts. For example, the recent rage over NFTs was backed by Ethereum.
That’s it, thanks for listening, bye!