Title Text

Digital Currencies & Blockchain

Lecture 4

  • Ethereum
     
  • Smart Contracts

Content

Title Text

Unlike Bitcoin, which has a very limited scripting language, Ethereum is designed to be a general- purpose programmable blockchain that runs a virtual machine capable of executing code of arbitrary and unbounded complexity.
 

Where Bitcoin’s Script language is, intentionally, constrained to simple true/false evaluation of spending conditions, Ethereum’s language is Turing complete, meaning that Ethereum can straightforwardly function as a general-purpose computer.

Ethereum

Title Text

- White Paper revealed in 2013 by Vitalik Buterin, Genesis Block mined on 30th July 2015

  • Block #0 - "Frontier" - The initial stage of Ethereum, lasted from July 30th 2015 to March 2016.
     
  • Block #1,150,000 - "Homestead" - The second stage of Ethereum, launched in March 2016.
     

  • "Metropolis Byzantium" - Metropolis is the third stage of Ethereum, launched in October 2017. Has 2 subforks: Byzantium and Constantinopole.
     

  • Serenity - November 2020 - phase 0, Phase 1 and 2 unknown

Roadmap

Title Text

A DApp is composed of at least:
 

• Smart contracts on a blockchain

 • A web front-end user-interface.

 

In addition, many DApps include other decentralized components:
 

• A decentralized (P2P) storage protocol and platform.

- Costs of Storage at Filecoin: https://filstats.com/​

• A decentralized (P2P) messaging protocol and platform


     

Decentralized apps

Title Text

Costs of Storage

Title Text

  • 1 ether is 1 quintillion wei (1 x 1018 or 1,000,000,000,000,000,000).
     
  • Externally Owned Accounts (EOAs) - have a private key;
     
  • Contract account has smart contract code, which a simple EOA can’t have. Furthermore, a contract account does not have a private key. Instead, it is owned (and controlled) by the logic of its smart contract code: the software program recorded on the Ethereum blockchain at the contract account’s creation and executed by the EVM.

    • have an address, just like EOAs. Contracts can send and receive ether, just like EOAs. However, when a transaction destination is a contract address, it causes that contract to run in the EVM, using the transaction, and the transaction’s data, as its input

Title Text


MetaMask.io - is a browser extension wallet that runs in your browser (Chrome, Firefox, Opera or Brave Browser). It is easy to use and convenient for testing, as it is able to connect to a variety of Ethereum nodes and test blockchains. MetaMask is a web-based wallet. Supported by Trezor or Ledger.

Jaxx - is a multi-platform and multi-currency wallet that runs on a variety of operating systems including Android, iOS, Windows, Mac, and Linux. It is often a good choice for new users as it is designed for simplicity and ease of use. Jaxx is either a mobile or desktop wallet, depending on where you install it.


MyEtherWallet (MEW) is a web-based wallet that runs in any browser. It has multiple sophisticated features we will explore in many of our examples.


  • Other: Argent, Dharma, 

Wallets

www.etherscan.io

 

www.dappradar.com

Explorer

Title Text

  • LLL - A functional (declarative) programming language, with Lisp-like syntax. It was the first high- level language for Ethereum smart contracts but is rarely used today.
  • Serpent - A procedural (imperative) programming language with a syntax similar to Python. Can also be used to write functional (declarative) code, though it is not entirely free of side effects.
  • Solidity - A procedural (imperative) programming language with a syntax similar to JavaScript, C++ or Java. The most popular and frequently used language for Ethereum smart contracts.
  • Vyper  - A more recently developed language, similar to Serpent and again with Python-like syntax. Intended to get closer to a pure-functional Python-like language than Serpent, but not to replace Serpent.
  • Bamboo  - A newly developed language, influenced by Erlang, with explicit state transitions and without iterative flows (loops). Intended to reduce side effects and increase auditability. Very new and yet to be widely adopted.
  • Soon --> Web Assembly: https://nirolution.com/ethereum-ewasm/

Languages

Title Text

  • Cryptography: https://en.wikipedia.org/wiki/Cryptography
  • Trapdoor Function: https://en.wikipedia.org/wiki/Trapdoor_function
  • Prime Factorization: https://en.wikipedia.org/wiki/Integer_factorization
  • Discrete Logarithm: https://en.wikipedia.org/wiki/Discrete_logarithm
  • Elliptic Curve Cryptography: https://en.wikipedia.org/wiki/ Elliptic_curve_cryptography

 

Cryptography

Title Text

Currently, there are six main implementations of the Ethereum
protocol, written in six different languages:

  • Parity, written in Rust

  • Geth, written in Go

  • cpp-ethereum, written in C++

  • pyethereum, written in Python •

  • Mantis, written in Scala,

  • and Harmony, written in Java.

 

Clients

Title Text

Gas is Ethereum’s unit for measuring the computational and storage resources required to perform actions on the Ethereum blockchain. In contrast to Bitcoin, whose transaction fees only take into account the size of a transaction in kilobytes, Ethereum must account for every computational step performed by transactions and smart contract code execution.

• Adding two numbers costs 3 gas
• Calculating a Keccak256 hash costs 30 gas + 6 gas for each 256 bits of data being hashed
• Sending a transaction costs 21,000 gas

Gas is a crucial component of Ethereum, and serves a dual role: as a buffer between the (volatile) price of Ethereum and the reward to miners for the work they do, and as a defense against denial of service attacks.

Gas

Title Text

Represents the units of gas required to run each operation. The gas cost of each operation on the Ethereum blockchain was predetermined in the yellow paper.

 

For instance, the gas cost of running an “addition” operation is 3 gas, and will remain 3 gas regardless of the USD value of ether. This clarification provides further insight into why we use gas instead of directly associating ether with the cost of running an operation.

 

Whereas the amount of gas needed to run a single operation cannot be easily changed by the network, the price of gas in ether can easily respond to the volatility of ether or to network traffic.

Gas Costs

Title Text

Is the value of a unit of gas in ether. Gas price is measured in “Gwei.” One Gwei is 1 billion Wei, and a Wei is the smallest unit of ether.

Sites such as ethgasstation.info post the average gas price on the network, but users may be willing to set a higher gas price on their transaction to be prioritized by miners.

 

Miners keep the gas (or, more exactly, the ether one pays that represents gas) that a user attaches to a transaction.

 

They will prioritize, therefore, a transaction that has a higher gas price associated with it over other transactions with a lower gas price.

Gas Price

Title Text

Gas Limit is the maximum amount of gas one is willing to spend on a particular transaction. The gas limit can be, and typically is, greater than the actual amount of gas the transaction requires.

 

If a user specifies a gas limit that is too low (i.e. the operations within the transaction collectively require more gas than the user attaches to the transaction), then a miner will complete the transaction until the gas is used up.

 

At that point, the miner would keep the fees (as they spent time and energy on executing as many of the operations as they could), the transaction would fail, and the blockchain would keep a record of the transaction as “failed.” Gas limits exist to protect users and miners both from losing funds (for users) and energy (for miners) from faulty codes or malicious attacks.

Gas Limit

Title Text

Gas Limit History

Title Text

  • Self-executable pieces of software
     
  • Run on a decentralized network
     
  • Unstoppable
     
  • Virtually any kind of applications
     
  •  But with a slightly different design logic
     
  • Better naming: "Persistent Scripts"

 

Smart Contracts

Title Text

Web 3.0

ICOs

Title Text

Title Text

Title Text

ETH Killers

  • Cardano
  • Polkadot
  • Cosmos
  • Avalanche
  • Dfinity
  • Near
  • Eos
  • Tezos
  • Tron
  • Neo
  • NEM

Title Text

Ethereum 2.0

DeFi 

DeFi - November 2018

DeFi - May 2019

DeFi - March 2020

Title Text

Title Text

Title Text

Non-fungible Tokens

Non-fungible contracts

Convergence

Readings

Recommended:

UNI - L4

By David Stancel

UNI - L4

Ethereum

  • 1,245