In 2009, Satoshi Nakamoto introduced a radical development in the financial industry by creating a digital asset which could store value, despite lacking a central issuer and having no intrinsic value. Bitcoin uses blockchain technology to record a history of all transactions, ensuring that once a token is spent, it stays spent.
Ethereum is often described as blockchain 2.0. In many ways, the cryptocurrency invented by Vitalik Buterin and others is an extrapolation of Nakamoto’s work. It develops on Bitcoin’s foundations by adding Smart Contract functionality, an addition which allows decentralized applications to be built on top of the Ethereum blockchain.
In order to facilitate Smart Contracts, Ethereum also needed to find a new way to process transactions. It’s worth noting at this point, that cryptocurrency transactions are only superficially similar to the typical offline equivalent.
A typical offline transaction might consist of me handing you five dollars. Two things change at that moment: 1) the physical location of the money (the five dollars are now in your pocket, instead of mine) and 2) the person who owns the money (the five dollars now belong to you, rather than me).
Replicating these conditions with a digital asset is incredibly complex because it requires a “state transition system”. The system needs to not only account for the current ownership of all existing tokens but also shift ownership from once the transaction is performed.
No cryptocurrency processes more transactions than Ethereum, let’s discuss how they work in more detail.
What are Ethereum Accounts?
All Ethereum transactions require an account.
An Ethereum account is a 20-byte address which is able to store the “state” of ownership of ether tokens. All transactions are transitions of ownership between Ethereum accounts. In order to process the transition, an account has four fields:
- A counter used to ensure each transaction is only processed once, called a nonce
- The account owners ether balance
- The account’s smart contract code
- The account’s storage
Importantly, Ethereum has two different kinds of accounts. The first is known as an externally owned account. This is a typical cryptocurrency account, where the owner controls the private keys providing access to the account.
The other type is a contract account, which is controlled by contract code. Here we see another important step in the evolution from Bitcoin to Ethereum. In Bitcoin’s case, only external accounts exist, but Ethereum needs contract accounts to execute smart contract transactions. More specifically, whenever a contract account receives a message the code therein activates, in turn sending other messages or even creating new contracts.
What is the anatomy of an Ethereum transaction?
As mentioned previously, transitioning the state of ownership of a digital asset from one account to another is not an easy task. In order to accomplish this, Ethereum transactions are essentially signed data packages, containing a host of information to make the transition possible.
An Ethereum transaction consists of:
- The recipient address
- The sender’s signature
- The transaction amount
- The gas price value – this determines how much the sender pays per computational step
- The Start gas value – this controls how many computational steps the transaction is allowed to execute
- An optional data field
The top three values are the same for almost all cryptocurrency transactions. Bitcoin transactions, for example, contain all three fields as well.
That said, the gas and start price values are unique to Ethereum transactions and play a vital role in protecting the network from spam attacks. Without robust defensive measures, malicious actors could design smart contracts to expend vast amounts of computational energy to overload the network.
By introducing a concept called gas, the Ethereum protocol ensures that each computation on the network comes at a price. As a rule of thumb, one computation costs one gas. Gas has a monetary value, making it exceptionally expensive to launch such an attack. Additionally, the Start gas value is included to limit the number of computations a transaction is allowed to execute, further helping to fight spam attacks.
How does ownership transition on the Ethereum blockchain?
By now we understand what a transaction is on a technical level, and what data is required to perform one. Now it’s time to look at how transactions manage to transfer ownership of a token on the Ethereum blockchain.
The Ethereum Whitepaper provides this simplified graphic to illustrate how the “state transition system” works in detail.
Source: Ethereum Whitepaper
To be more precise, a transaction goes through a series of steps before being successfully completed.
First, the Ethereum blockchain checks to see if the transaction contains all the data listed above, and has a valid signature. If the nonce also matches, the transaction moves on to the second step.
Here the transaction fee is calculated. In very simple terms, this is done by multiplying the Start gas with the gas Price value contained in the transaction and adding one gas per computation. Once calculated, the fee is applied to the sender’s external account.
If the account cannot cover the fee, or the transaction does not contain a valid signature, the transaction fails, producing an error. Part of the genius of Ethereum is that it manages to completely revert the transaction in case of an error.
If all the conditions are met, the state of ownership is transitioned from the sender to the recipient. In the case that the recipient account is a contract account, the code is run to completion or until the predesignated gas runs out.
That, in a nutshell, is how Ethereum transactions work.
Why does Ethereum become congested?
So far we have seen how brilliantly Ethereum handles transactions. Not only does it develop the state transition system, but it also pioneered contract accounts capable of executing complex code.
Nevertheless, Ethereum still has one or two issues which routinely cause congestion on the network. Congestion, in the context of cryptocurrencies, refers to a situation in which transactions are processed at a greatly reduced speed, causing the number of pending transactions to ramp up.
The most famous case of congestion occurred in December 2017, when a popular game called Cryptokitties, single-handedly brought the network to a grinding stop. Below you can see a chart showing pending transaction during the first days of December.
This level of congestion was possible because Cryptokitties is a DAPP that relies on transactions to perform basic aspects of the game. Therefore, the more users played the game, the more transactions were propagated to the blockchain.
Unfortunately, Ethereum’s Proof-of-Work consensus model relies on miners, and fixed block sizes, just like Bitcoin. The result is a severe lack of scalability and out of control transaction fees.
In the case of Cryptokitties, this is exactly what happened. The network simply didn’t have the capacity to deal with the sudden influx of activity. As transactions were experiencing significant delays, users began increasing the amount of gas in an effort to entice miners to process their transaction first.
Even the company behind Cryptokitties – the DAPP that was responsible for the congestion – began to incentivize miners to process their transactions, further exacerbating the problem.
???? Due to network congestion, we are increasing the birthing fee from 0.001 ETH to 0.002 ETH. This will ensure your kittens are born on time! The extra is needed to incentivize miners to add birthing txs to the chain. Long-term solution will be explored very soon! ????
— CryptKitties ?? (@CryptoKitties) December 3, 2017
This caused the average transaction fee to balloon from $0.20 in November, to $1.45 in December. When the game reached the height of its popularity in January 2018, the average fee for a transaction had climbed to $4.15.
The level of congestion caused by one relatively popular DAPP has given many of us food for thought. At its core, the problem revolves around the lack of scalability backed into Ethereum’s consensus model.
Interestingly, a replacement for POW – called Casper – has been in the works for some time, but progress seems to be limited. If successful, Casper would be a unique take on a Proof-of-Stake model, relying on token holders (or stakeholders) to validate transactions on the blockchain. The basic idea relies on the fact that someone holding Ether would only harm himself by acting maliciously towards the network. Stakeholders who are caught acting maliciously also stand to lose their Ether, meaning that the network would have leverage over bad actors.
One of the benefits of Casper is that it would remove the need for the energy expensive POW, eliminating miners, and vastly improving scalability. With all these advantages in mind, it’s a shame that Casper hasn’t made more significant progress. Nevertheless, I have my fingers crossed that the days of POW on the Ethereum blockchain are coming to an end.
Conclusion – How Ethereum transactions work
Ethereum has managed to make significant, incremental improvements on Bitcoin’s pioneering work. The introduction of smart contract functionality has ramifications far beyond the financial world. Governments, multi-national corporations, and entrepreneurs alike are finding ways of innovating entire industries with the help of the Ethereum blockchain.
Importantly, none of this would be possible without Ethereum’s state transition system. Transactions form the heart of the cryptocurrency, and it’s clear to see how exciting this technology really is.