Ethereum For The Average Joe

Ethereum is a decentralized application and smart contract platform on the blockchain. Before we dive into what all of that means, you must understand what a blockchain is.

Blockchain Explanation

* knowledge about bitcoin would be useful*

A blockchain is a distributed, immutable, public ledger.

Distributed meaning there is no master copy by one person. They are many synchronized versions of the blockchain on nodes(computers) all around the world.

Immutable meaning that once a transaction is present in the blockchain for an hour or two, altering or erasing it becomes impossible. This is because it requires a lot of computational power to undo the transaction.

A ledger is simply a list of transaction in a blockchain.

To understand how several people are able to keep their copies of the database in sync with everyone else, imagine there are 100 nodes in a network. Everyone is sitting with an empty file folder and an empty page in front of them. Whenever anyone does something important in the network, like transferring money, they announce it to everyone in the network.

Everyone makes a note of the announcement on their pages until the page is filled. When it is filled, the person who filled it has to seal the contents of their page by solving a mathematical puzzle. The first person who solves the mathematical puzzle gets the right to copy their version of the notes and send them to everybody elses folders as the official version. However, everyone is obliged to decline someone elses version if they find mistakes in it. Solving the puzzle can not ensure everybody took the same notes in same order. Only the fastest solver gets to decide which notes are to be included on the page and which have to wait further. They are still unable to forge the notes, because everybody can check after them.

Once the page is sealed, the page is added to the file folder, everybody brings out a new page and the process cycles infinitely. As time passes, these pages (blocks) that contain important records are added to the folder thus forming the database.

Uses of Blockchain

Bitcoin uses the blockchain to store records of financial transactions, acting like a bank to guarantee security and trust. However, Bitcoin does not allow for business logic and people started to realized Bitcoin was restrictive in programming money and building applications onto the blockchain. Building basic applications like a crowdfunding app with no central authority required months of work even for seasoned programmers. There needed to be a better solution.

How does Ethereum work

Just like any other blockchain, Ethereum requires many nodes running a software on their computer to guarantee security and trust. Every node participating in the Ethereum protocol runs a software on their computer called the Ethereum Virtual Machine(EVM). The EVM is a system which understands and executes all the software written in a specific Ethereum programming language - Solidity (similar to Javascript) and Serpent (similar to Python). The applications or software run by the EVM are called "smart contracts".

This is what makes Ethereum a world computer, but an expensive and slow one. It has about the same processing power as a 90's smartphone. You may be asking, if that is true, why would anyone use Ethereum? Well, we will talk about that.

To run any smart contract, you must pay a price so no unlimited loops can be run which crashes the system and suck all the resources. You must pay this price in Ethers, the native cryptocurrency to Ethereum. Ether is to Ethereum as Bitcoin(currency) is to Bitcoin(system). We will talk about this in more detail later.

In Ethereum, they are 2 types of accounts or users.

1. Externally Owned Accounts => accounts owned by some external entity (say a person or company), can send and receive Ether's.

2. Contract Accounts => smart contracts, can send and receive Ethers just like externally owner accounts but can also run a predefined computer program to perform various actions when triggered.

Example

Let's say Mike and Annie want to place a bet on a soccer game. Mike is a huge fan of the team Real Madrid and Annie is an ardent supporter of FC Barcelona(rivals). There is a Real Madrid vs FC Barcelona game coming up in a few days. They agree to a bet with the conditions that the losing team's fan will have to pay the other $500. They are many ways to go about this, with each having its unique pros and cons

1. Trusting each other
This could work as both Mike and Annie are friends and the amount they are betting is not too much. However what if they were strangers who did not trust each other? What if this was a large amount of money and they did not want any cheating happening?

2. Get help from a friend they both knew and trusted
This could work as they would both give their $500 to their friend, let's call him Johnny. After the match had ended, Johnny could check the score and give the $1000 to the winner. However, this method has similar shortcomings to the first method of both Mike and Annie trusting each other. If they were strangers, how would this work? Is there another cheap and easy way which guarantees the winner will get $1000 after the match?

3. Signing a Legal Agreement
Sure they could go to court and both sign an agreement that defines all the terms of the bet and the consequence for the loser. However, this process would be incredibly time consuming and expensive. It would not be worth it to go through this hassle.

Creating a smart contract on the Ethereum blockchain could help save Annie and Mike's day in this case. They could write code that accepts $500 from both of their Ethereum accounts, and then the next day uses an API to check the match score and transfer the Ether worth of $1000 to the winner. Win-win situation. A smart contract is immutable because it is in the blockchain. No one can do any editing or altering.

How does this work on the blockchain?

Well when a smart contract is executed, all the information and conditions present in the smart contract are recorded onto a transaction which (hopefully) eventually makes it on to a block and onto the blockchain.

They are 3 main kinds of transactions you can find on the Ethereum blockchain.

1. Transfer of Ether from one account to another account
These are Bitcoin-like transactions. An example would be sending 1 Ether to your landlord for your rent payment. At a high level, this transaction contains: a timestamp, your ether address which has your funds in it, your landlord's address, and the amount you want to send.

2. Transfer of ether from a user to no one
These transactions are used to create a smart contract. Let's say Annie and Mike are smart and decided to create a smart contract with the conditions of the bet. The transaction will contain a timestamp and the sender's ether account. However, there will be 2 major difference between this contact creating transaction and the transaction to your landlord. First of all, this transaction will have no recipient. The second difference is that this transaction has a special "data field". This "data field" is what makes Ethereum different from other digital currencies. This data field is used to record the creation and execution of smart contracts. So, this data field will contain the code that lists the conditions and consequences of the bet.

3. Transfers of ether from externally owned account to a smart contact
Whenever an account wants to execute a smart contract, they must make a transaction to the smart contract and put the instructions for the execution in the data field so the contract can know what to trigger.

Whenever any of the above 3 transactions happen, the whole network writes in down in their folder. However, additionally, each node will execute the smart contract code in their EVM.

Smart Contract Price?

Every smart contract must pay a certain price for the EVM to execute it. This price is paid to the node that spent its memory, storage, computation, and electricity to execute and verify the smart contract.

To calculate the prices of smart contracts, every statement has an assigned cost to it. This cost is paid and defined in Gas. Eventually, gas is converted to ether using an exchange rate. Whenever you execute a smart contract, you have to define the maximum Gas to be consumed. The execution will stop either when the execution is completed or when the gas limit is reached. This is done to avoid infinite loops in smart contracts, preventing the program getting stuck executing a set of transactions and eventually crashing.

The concept of Gas solves the problem of infinite loops. It doesn't make sense for a node to crash and be stuck executing for infinity.

Conclusion

That is Ethereum. It allows for the first time in history, money to be programmable. Places where they are traditionally multiple third parties which make the process slow are now not necessary. With Ethereum, a piece of code could automatically transfer the home ownership to the buyer and the funds to the seller after a deal is agreed upon without needing a third party to execute on their behalf.



Star