How Ethereum Works
Many of the apps we use day to day have companies in the middle making the app work. YouTube stores videos for people to view. Robinhood holds our money for investing in stocks. Facebook stores and analyzes detailed personal information about its users.
Ethereum is a platform that aims to make it easier to create applications that aren’t managed or controlled by one entity. Instead they are governed by code.
Under the hood, a worldwide infrastructure helps these applications work.
Ethereum borrows heavily from Bitcoin’s protocol and its underlying blockchain technology, but it adapts the tech to support applications beyond money. Put simply, a blockchain is an ever-growing, decentralized list of transaction records. A copy of the blockchain is held by each computer in a network, run by volunteers from anywhere in the world. This global apparatus replaces intermediaries.
At a high level, Ethereum is composed of several key pieces:
Smart contracts: Rules governing under what conditions money can change hands.
The Ethereum Virtual Machine (EVM): The part of Ethereum that executes the rules of Ethereum, and makes sure a submitted transaction or smart contract follows the rules.
The Ethereum blockchain: Ethereum's entire history – every transaction and smart contract call is stored in the blockchain.
Ether: Ethereum's token, which is required to make transactions and execute smart contracts on Ethereum.
Proof-of-work: This is Ethereum’s consensus model, the glue holding the whole system together that ensures everyone on the network is following the rules.
Ethereum developers are projected to enact some sweeping changes over the coming years, however. Ethereum 2.0, which began rolling out on Dec. 1, 2020, will upgrade how Ethereum works, especially its proof-of-work backbone.
Ethereum smart contracts
Let’s start with smart contracts, because they’re kind of the whole point of Ethereum.
Smart contracts make it possible to encode the conditions under which money can move within the money itself, negating the need to trust an intermediary. They are a part of any cryptocurrency. Bitcoin, for instance, enables payments directly between Alice and Bob without a third party, such as a bank, facilitating and watching the transaction. Before cryptocurrency, that was not possible in online commerce.
Ethereum aims to expand smart contracts by abstracting away Bitcoin’s design so developers can use the technology for more than simple transactions, expanding its use to agreements with additional steps and new rules of ownership. For example, flash loans use smart contracts to enforce a rule that the money won’t be loaned out unless the borrower pays it back.
Some Ethereum services, such as Compound, are experimenting with allowing users to loan or borrow money with smart contracts managing the money rather than a company.
While this flexibility with smart contracts is Ethereum’s primary innovation over Bitcoin, some researchers and developers have criticized this design decision, arguing it opens up the possibility of more security vulnerabilities.
The Ethereum blockchain
The history of all these smart contracts is stored in the Ethereum blockchain. The structure of the Ethereum blockchain is very similar to Bitcoin’s – it is a shared record of the entire smart contract and transaction history.
Hundreds of volunteers from around the world store a copy of the complete Ethereum blockchain, which is quite long. This is one feature that makes Ethereum decentralized.
Each of these is called a “node” in Ethereum’s network. Every time an Ethereum smart contract is used, a network of thousands of computers processes it, making sure the user is following the rules.
All of these nodes are connected. In addition to storing this data, each Ethereum node follows the same set of rules for accepting transactions and running smart contracts.
In contrast to Bitcoin, Ethereum nodes store more than just transaction details. The network needs to keep track of the “state” – or the current information – of all of these applications, including each user’s balance, all the smart contract code, where it’s all stored, and any changes that are made.
Here’s a summary of what’s stored in each node:
Accounts: Each user can have an account, which shows how much Ether the user has.
Smart contract code: Ethereum stores smart contracts, which describe the rules that need to be met for money to be unlocked and transferred.
Smart contract state: The state of the smart contracts.
The Ethereum Virtual Machine (EVM)
Each Ethererum node also has an Ethereum Virtual Machine (EVM) that executes the smart contracts. All the nodes run in sync.
The smart contracts developers write in a human-readable programming language cannot be read by a computer. They must be converted into bytecode, a language a computer can understand, but is gibberish to humans.
Then the EVM takes over. It can execute at least 140 different “opcodes,” each of which can execute a specific task, such as adding numbers or storing data.
Ether and Ethereum transactions
How do users interact with Ethereum?
Using smart contracts and using Ethereum apps requires money in the form of ether, Ethereum’s native token. Ether is needed for doing just about anything on Ethereum, and when it’s used to execute smart contacts on the network it’s often referred to as “gas.” The ether can be used to call smart contracts: For example, a contract could trigger a post on Twitter (or an alternative), or it could trigger an account to begin borrowing coins on an Ethereum-based lending platform.
Ethereum uses accounts to store the ether, analogous to bank accounts.
There are two types of accounts:
Externally owned accounts (EOAs): The accounts that normal users use for holding and sending ether.
Contract accounts: These separate accounts are the ones that hold smart contracts, which can be triggered by ether transactions from EOAs or other events.
Calling smart contracts isn’t free. Each transaction costs some ether, which increases depending on how much computation the transaction is using. Also, when Ethereum is congested, fees go up.
Find more about accounts here.
Ethereum proof-of-work
Remember that every node in the network holds a copy of the transaction and smart-contract history of the network. Every time a user performs some action, all of the nodes on the network need to come to agreement that this change took place.
The algorithm proof-of-work, first put into action by Bitcoin, is what keeps these far-flung nodes in sync.
Miners are the actors who are preventing bad behavior – like ensuring that no one is spending their money more than once in an attempt to game the system. Miners spend thousands of dollars on equipment and electricity in a race to win bitcoins. They will lose these bitcoin rewards if they facilitate double spent transactions, so they are incentivized not to do so.
The goal here is for the network of miners and nodes to take responsibility for transferring the shift from state to state, rather than some authority such as PayPal or a bank. Bitcoin miners validate the shift of ownership of bitcoins from one person to another. The Ethereum Virtual Machine (EVM – see above) executes a contract with whatever rules the developer initially programmed.
But, Ethereum might not be using proof-of-work for long. Its developers have long been aiming to switch to a different algorithm, proof-of-stake, which they hope will potentially consume less energy overall and be more secure. The algorithm is controversial in some circles. Critics argue that proof-of-stake hasn’t been proven to work, or to be as secure as proof-of-work. Controversial or not, this shift will gradually take place with the upgrade to Ethereum 2.0, which started on Dec. 1, 2020.
Ethereum FAQ
How will Ethereum 2.0 change how Ethereum works?
When fully implemented (estimated in a few years), Ethereum 2.0 will dramatically change how Ethereum works. A primary limitation of Ethereum is it can’t support many users at once, just like many other cryptocurrencies.
Even with Ethereum 2.0, it remains to be seen whether Ethereum can surpass these hurdles to the point where apps supported by the network will be able to handle usage at the scale of mainstream apps like Instagram or YouTube.
Why have Ethereum gas fees been going up recently?
This is an integral part of Ethereum. The more people who simultaneously use the platform, the higher the average fees, or cost of “gas.” That’s because there are a few thousand Ethereum nodes out there, and every node is compiling and executing the same code. But, you might be thinking, isn’t that much more expensive than a normal computation? Yes, it is. Developers are trying to make it cheaper.
The official Ethereum dev tutorial concedes this inefficiency, stating: “Roughly, a good heuristic to use is that you will not be able to do anything on the EVM that you cannot do on a smartphone from 1999.”
Where can I learn more about how Ethereum works?
We’ve only just scratched the surface. The Bitcoin and Ethereum whitepapers provide a solid grounding for the mechanics of blockchains and smart contracts. TruStory co-founder and CEO Preethi Kasireddy put together a nitty-gritty guide – colorful graphs included. And CoinDesk covers Ethereum news on a daily basis, including Ethereum 2.0 progress and setbacks, which will overhaul how Ethereum works.