3. Ethereum#

Similar to the previous tutorial, we’ll explore how to utilise the Ethereum blockchain. We’ll begin by examining the transaction we completed at the end of the last tutorial, attempting to trace how the Ether ended up in our account. Along the way, we’ll explain the differences between Ethereum transactions and Bitcoin transactions.

Next, we’ll provide a brief overview of how to send assets to another Ethereum account. This information will be useful, for example, when transferring money to a friend or making payments for services.

Finally, we’ll wrap up by briefly discussing smart contracts and how they distinguish Ethereum from Bitcoin.

Analysing an Ethereum transaction#

At the end of the previous tutorial we converted some Bitcoin into Ether, and sent it to our Ethereum wallet. We analysed what happened in this conversion process on the ‘Bitcoin’ side of things, so for this tutorial, let’s start off by analysing what happened on the Ethereum blockchain during this process. The analogue to Blockchair for Ethereum is called Etherscan, and that’s what we shall be using during this tutorial.

Ethereum (ETH) Blockchain Explorer

First, let’s open the MetaMask wallet, copy our address and search for it on Etherscan. You should see something like the following:

Untitled

This is our Ethereum account, and in this account you can see your transaction history (anyone who knows your address can access this history), the coins you hold, whether you have any NFTs and whether this address has transacted on any other chain (more on all these in the future). For now we’re going to focus on the one incoming transaction, which should be the transaction we completed using THORSwap, sending the Ether that we converted our Bitcoin into to our wallet. If we click on the “Parent Txn hash” or “Parent transaction hash” below, we will be redirected to a page that looks like this:

Untitled

We recognise many of the features present in the Bitcoin transaction; the gas fee, a block ID (which is just called “Block”), a timestamp and the analogue to “fee per vByte” in “Gas Price”. However, we might also notice that there is only one sender and one receiver. This brings us to the largest difference between the Ethereum and the Bitcoin blockchains.

Ethereum accounts#

In the first tutorial, we hinted that you can visualise your wallet as a physical wallet and your crypto account as a bank card. In the second tutorial, we compared Bitcoin to cash. Well, when it comes to Ethereum, it aligns more with the wallet-as-a-bank-account analogy. Ethereum operates more like a bank account, which means it sacrifices some of the privacy features found in Bitcoin.

Unlike Bitcoin, Ethereum doesn’t keep track of individual ‘bills’ in your account; it only records your total balance. When funds are deposited, your balance increases, and when you make withdrawals, your balance decreases. Practically, this makes it easy to trace transactions associated with a single account because all information is readily available. However, it’s impossible to trace the path of an individual unit of currency since all funds in your balance are perfectly fungible. Additionally, Ethereum transactions typically involve a single sender and a single recipient, making it easier to read individual transactions.

You can visualise Ethereum accounts using a state diagram. Unlike Bitcoin, there are no discrete ‘bills.’ Instead, Ethereum has a single balance for each coin within its ecosystem. In the initial state, Alice holds 3 Ether and 1 wrapped Bitcoin (a coin on the Ethereum ecosystem pegged to the value of Bitcoin), while Bob holds 2 Ether. After a transaction in which Alice sends 2 Ether to Bob, Bob’s balance increases by 2 Ether, and Alice’s balance decreases by 2 Ether. There are no UTXOs or change involved in this transaction.

Untitled

Inspecting transactions#

This doesn’t mean that understanding an Ethereum transaction is always straightforward, however - if you look closely, you will notice that neither the ‘From’ nor the ‘To’ addresses match up with your Ethereum address, let’s first look at the sender address.

Untitled

The first thing you might notice is that there is a “(pending)” transaction, this is a transaction that has been submitted to the Ethereum mempool(s) (the ‘mempools’ works the same way for Ethereum as it does for Bitcoin) and for whatever reason hasn’t been added to the Blockchain, mostly likely due to the gas fee paid being too low. What you might notice after that is that any transaction that is flagged by Etherscan as “Out” goes to the address that starts with 0xD37BbE…, and that any transaction that is flagged as “In” comes from a different address. Furthermore, the address starting with 0xD37BbE is in the “To” field in the THORSwap transaction on our own address. We need one more piece before we can put the puzzle together - the sender address has a lot of Ethereum in it, but if we look a the 0xD37BbE address itself then it has no Ethereum in it at all. This is all indicative that the 0xD37BbE address is some kind of middle man (only confirmed by the fact that Etherscan says “Contract” rather than “Address” next to it - the specifics of this will be explained in the next tutorial) and the sender address is the THORSwap controlled address, which holds a reserve of Ethereum that is used to pay people for their swaps (imagine HSBC dollar reserves). The “In” transactions are most likely people topping up the reserves when they fall too low.

Now if we go back to the original transaction:

Untitled

Underneath the 0xD37BbE… address, there is a little line that says “Transfer … From … To …” what this means is that the address 0xD37BbE automatically forwarded the money sent to it by the address 0x88EDe to, in the screenshot, 0xA6dA6 - which in your case, if you are following along, should be your own Ethereum address.

How to get your transactions out of the Mempool in Ethereum#

Before we go further, let’s quickly circle back to the pending transactions. It can quite often happen that you get your transaction stuck in the mempool, or you don’t want it to be executed because you made a mistake. While in Bitcoin, you can reuse the same UTXO with a higher fee to override a transaction, Ethereum, which doesn’t use UTXOs, operates differently. Ethereum keeps track of transactions through a ‘nonce,’ which is essentially a transaction counter. Each account has its own nonce, starting with 0 for the first transaction and incrementing with each subsequent transaction.

If a transaction from the same account is in the mempool and has a nonce that has already been used, it will be considered invalid and not added to the Ethereum blockchain. Therefore, if you have a transaction stuck in the mempool, you can send a new transaction with the same nonce but a higher transaction fee. This increases the chances of the new transaction being picked up first, effectively canceling out the stuck transaction. Although there is always the chance that a miner doesn’t receive your second transaction fast enough so the first one gets put in a block before the second one.

Block confirmation in Ethereum#

If you look at the transaction, next to the date at which it was sent there should also be some text that says “Confirmed within N secs”. This means that it spent N seconds in the mempool before it was added to the Blockchain. As previously discussed, the “block time” (the amount of time it takes to mine a block) in Bitcoin was about 10 minutes. In Ethereum, it is about 14 seconds. It is important to ask, why is there such a difference between Bitcoin and Ethereum? It’s a question of security - a longer block time means it’s harder for someone to manipulate the network. At the same time though, a longer block time means that it’s more inconvenient to use for payments. Hence, it all comes down to design decisions. Note that does not mean that Ethereum is not secure. If you’re interested in exactly how a faster block time affects Ethereum’s security see here: https://blog.ethereum.org/2015/09/14/on-slow-and-fast-block-times.

How gas works in Ethereum#

Just like in Bitcoin, the miners (who are now called ‘validators’, due to an update in the way Ethereum “mining” works) who add your transaction to the chain need to be compensated somehow, and just like Bitcoin there are three main ways that that is achieved. The first and simplest, is that every time someone mines a block, they are given 2ETH out of thin air. The second way that validators are compensated is gas fees, and the the third way they are compensated is by placing their own transactions in the middle of blocks to earn money from the price movements. We will only discuss gas fees, to read about the third form of compensation, you can click below: https://ethereum.org/en/developers/docs/mev/.

The gas price (note the terminology) in Ethereum can be broken down into two parts; a “base fee” that everyone needs to pay be be able to be included in the block, and then a “tip”. This is different from Bitcoin, which has no lower bound on the transaction fee to be included in a block. The “base fee” goes up if previous blocks have been full, and goes down if they have been empty. The crucial aspect of the base fee is that it doesn’t go to the validators (Ethereum miners); instead, it is entirely removed from circulation, or in Ethereum terminology, ‘burned.’ This helps counteract the inflationary impact of creating 2 ETH every time a block is mined. On the other hand, the ‘tip’ is similar to the transaction fee in Bitcoin. It represents the amount users are willing to pay in addition to the base fee to have their transaction included in the block. Users can compete based on the price they offer to be included sooner.

This setup makes it so that gas prices vary wildly during the day. If we look at the average gas price over an hour from a Dune dashboard, we see that gas prices can more than double during the day (interestingly 12:00 UTC is 8:00 New York time, whether this is the effect of just New York or the entirety of America waking up or something else entirely, I cannot say). So generally when you’re transacting, it is advised that you try and do it early in the morning.

Untitled

Further (just like Bitcoin) Ethereum charges depending on the complexity of the transaction. This is especially important, since Ethereum is made for having code executed by it. Every computational operation, like writing to memory, has a gas unit attached to it. The gas price represents the cost of a computational unit (referred to as ‘gas’ units), and the total gas fee is determined by multiplying the gas fee by the number of gas units consumed in the transaction.

Gas fee = gas price · gas units consumed

The gas price is usually denominated in Gwei, which is one billionth of an Ether.

Sending assets to an address in Ethereum#

This section does not require you to follow along. Now let’s say that we want to send some money to a friend, or pay for a service on Ethereum using MetaMask. Just like with Bitcoin, it is fairly straightforward. The only thing you need to provide is the amount that you’re sending, and the other person’s address. First, you want to select the ‘send’ option in your MetaMask wallet.

Screenshot 2023-08-29 182738.png

On the next screen, you will get to choose who you send your money to by entering their address in the field on the top. You can also enter an Ethereum Naming Service name, which is in the format of “name.eth”.

  • More on ENS

    The Ethereum Naming Service allows you to map human readable text into Ethereum addresses, so you can, for example be called Marten.eth instead of 0xad123… for ease of access. You can also integrate your existing .com or other domain into the ENS to be able to have names like Marten.com (if you own that domain already).

After you enter the address which you want to send money to, you will be directed to the screen where you enter the amount you want to send.

Untitled

Finally, you will reach the last confirmation screen where you can review the transaction details and confirm your acceptance. If everything looks good and you approve, the transaction is sent to the mempool, with the hope that it will soon be added to the blockchain.

Untitled

What sets Ethereum apart from Bitcoin?#

Throughout the preceding section, we’ve discussed Ethereum’s main advantage and why the upcoming tutorials in this series will primarily focus on Ethereum. That advantage lies in Ethereum’s Turing completeness, which means any piece of code you can run on your computer can also be executed on the Ethereum network. In practical terms, the code you submit to Ethereum is executed by someone else in the network, and the results can be stored on the blockchain. From a theoretical standpoint, Ethereum isn’t just a decentralised database; it’s also a decentralised computer. It’s not merely the Ethereum ledger; it’s the Ethereum Virtual Machine.

Smart contracts#

Smart contracts is the name given to programmes that live on the Ethereum Blockchain. Oftentimes, when smart contracts are mentioned, they conjure images of lawyers writing agreements that will be automatically enforced by code somewhere on the internet. There was even a time when people were discussing encompassing entire legal systems into smart contracts. Reality is often more mundane. A smart contract is nothing more than a piece of code on a blockchain, the execution of which is triggered by a transaction on the blockchain directly interacting with it - so they can’t even react to something happening on the blockchain that does not directly interact with it, and which can only read or write data on/to the blockchain. Indeed, in computer science jargon, it is probably better to use the word “script” for smart contracts, but the name has stuck and changing it now is near-impossible.

This doesn’t imply that smart contracts can’t perform remarkable tasks. However, it’s important to note that despite their incredible potential, they still have significant limitations and inefficiencies.

First, there’s the issue of storage cost. Generally, storing 1MB of data on the Ethereum blockchain costs around €57,000, making it financially unviable for large and complex applications.

Additionally, smart contracts are confined to their own blockchain. They lack awareness of the external world. For example, if you want your script to execute an action based on the price of gold, it can’t do so without external assistance because the price of gold isn’t available on the blockchain.

Lastly, from a legal perspective, there is no comprehensive legal framework governing smart contracts. This means that smart contracts aren’t legally binding contracts.

A few years ago, there were ideas in the crypto world about using Non-Fungible Tokens (NFTs, which we’ll explain in the 6th tutorial) to track house ownership. However, a fundamental problem arises: while you can sell the NFT associated with your house, there’s no legally binding mechanism that compels you to transfer ownership of the actual house.

Smart contracts and decentralised finance#

What smart contracts do enable is decentralised finance, or DeFi for short (as opposed to the traditional finance, or TradFi, that most people are more familiar with). As the name suggests, the greatest innovation of decentralised finance is that capital is decentralised. For example, let’s say that you want to convert euros into dollars. Instead of having to go through a broker, you can directly exchange on the crypto-euro and crypto-dollar market yourself, eliminating the middleman. While decentralisation is a key factor for many, it’s essential to exercise caution and discern what truly constitutes DeFi (Decentralized Finance) as opposed to what merely claims to be DeFi.

One of Ethereum’s significant advantages, stemming from its status as more than just a computer, is that you’re not limited to using only Ether on the Ethereum blockchain. You have the ability to create new currencies, often referred to as tokens, on the Ethereum platform. Nevertheless, Ether remains the native currency, and gas fees can only be paid in Ether. These tokens can be associated with various applications or even pegged to real-world assets.

Whitepapers#

The source of detailed information about a token should be something called a whitepaper. When DeFi projects release, it’s customary to put out a whitepaper at the same time, explaining what the project is, how it functions and what the token attached to the project should do. Before diving into any DeFi project, it’s a good idea to at least try and read the whitepapers of protocols you interact with, as it helps spot scams and frauds. When the whitepaper doesn’t make any sense or reads more like a marketing piece, that is generally a bad sign, and can be a warning to would-be project participants. Although concerning, poorly constructed whitepapers are not always evidence of a fraudulent project — some excellent projects also present badly in whitepapers. However, it’s important to note that these projects typically maintain some form of documentation elsewhere. Since these projects are open source, any code submitted to the blockchain is publicly viewable. Therefore, if developers intend for the project to have a lasting presence, they will usually release documentation.

Proof of work vs Proof of stake#

The final topic we’d like to discuss before concluding is the distinction between proof of work (PoW) and proof of stake (PoS) consensus mechanisms.

Starting with Bitcoin and PoW, in PoW-based blockchains, miners compete to select transactions from the mempool and find a number that solves a cryptographic problem. The process of finding this solution isn’t systematic, so miners essentially guess until they succeed. Once a miner finds a valid solution, they include it in a block with transactions and publish that block, which is then added to the blockchain. The drawback of PoW is that due to the guessing nature of the process, multiple miners duplicate work, and when one miner succeeds, the efforts of others become obsolete. This leads to high energy consumption, with Bitcoin estimated to consume about 127 TWh per year, equivalent to the energy consumption of countries like Argentina or Ukraine, each with a population of about 45 million. Considering Bitcoin processes roughly 900 million transactions annually, this energy use equates to roughly 20 transactions per person per year, consuming as much energy as an average Ukrainian household in 2018. Clearly, this model isn’t sustainable.

Now, let’s shift our focus to PoS-based blockchains. In PoS blockchains, only one person (or validator) validates transactions and adds them to the blockchain at a time. To ensure that validators don’t validate incorrect or malicious transactions, each validator is required to ‘stake’ a certain amount of cryptocurrency, in the case of Ethereum, Ether, as collateral in a smart contract. Although anyone can verify the transactions validated by the miner, if a fault is detected, they can challenge the validator. If a challenge is successful, the validator loses a portion of their staked collateral. To prevent a single validator from controlling all validation rewards, the system periodically rotates validators, selecting from those who have staked assets in the specified smart contract. For instance, in Ethereum, becoming a validator requires a deposit of 32 ETH, and there are no additional rewards for depositing more. As for the frequency of validator changes, Ethereum’s system is more intricate and involves committees, epochs, slots, and other technical terms that we won’t delve into here. If you’re interested in becoming a validator yourself and potentially earning around 4% APY (as of August 2023), here is a useful link to get started:

EthStaker knowledge base

Differences between Bitcoin vs Ethereum#

To summarise the differences between Ethereum and Bitcoin, we can categorise the main features of each blockchain as follows:

Bitcoin:

  1. UTXO based

    1. Offers better privacy for an individual user

    2. Makes tracing what money was used for easy

    3. Can send money to multiple recipients at the same time

  2. Limited programming

    1. Lower transactions fees

    2. Harder or impossible to build applications on top of

    3. Constrained to mostly be a currency

  3. 10 minute block times

    1. Slightly more security

    2. Less throughput in terms of transactions per second

    3. Slower transaction confirmation

  4. Inherently deflationary as supply is fixed

  5. Proof of work based

    1. Environmentally inefficient, as a lot of work is for naught

Ethereum:

  1. Account based

    1. Offers lower privacy for an individual user

    2. Makes tracing what money impossible

    3. Makes keeping track of everything simpler

  2. Fully Turing complete

    1. Higher transactions fees due to higher complexity

    2. Possible to build applications on top of

    3. Contains an entire decentralised financial system

  3. 14 second block times

    1. Slightly less security

    2. Higher throughput in terms of transactions per second

    3. Fast transaction confirmation

  4. Can be inflationary or deflationary depending on network demand (see here https://ethereum.org/en/roadmap/merge/issuance/)

  5. Proof of stake based

    1. Uses approximately 2000 times less energy and is thus massively better for the environment

DeFi and the next tutorial#

In the next tutorial, we will delve deeper into Ethereum and explore various decentralised finance (DeFi) applications. We will cover everything necessary to navigate and conduct transactions within the DeFi ecosystem.