A novice introduction to Ethereum (Part 1 / 2)

If you are new to Ethereum and want to quickly understand what’s going on, you’re on the right track. This post is exclusively made for you !

By the end of Part 1, you’ll be able to understand the key concepts of Ethereum!

In Part 2, you’ll code your own smart contract, compile it, deploy it on the Ethereum blockchain test network, and play with it!

Without further ado, let’s dive into it!

Key concepts

Blockchain

A blockchain is a growing list of records, called blocks, which are linked using cryptography. Each block contains a cryptographic hash of the previous block a timestamp, and transaction data. By design, a blockchain is resistant to modification of the data. It can be thought of as a global ledger or a database of all transactions containing the entire history of all transactions on the network.

Ethereum

Ethereum is an open source, public, blockchain-based distributed computing platform and operating system featur- ing smart contract (scripting) functionality.

Ethereum Virtual Machine

The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts in Ethereum. A runtime environment is the execution environment provided to an application or software by the operating system. Each full node in the Ethereum network locally runs its proper EVM. The Ethereum blockchain database, which contains all the transactions and smart contracts, is maintained and updated by many nodes connected to the network. Each and every node of the network runs the EVM and executes the same instructions. For this reason, Ethereum is sometimes described evocatively as a “world computer”.

Miner

Ethereum, like all blockchain technologies, uses an incentive-driven model of security. Consensus is based on choosing the block with the highest total difficulty. Miners compete to produce blocks which the others check for validity.

Proof-of-Work

Miners are tasked with solving a complex mathematical problem in order to successfully “mine” a block. This is known as a “Proof-of-Work”. Any computational problem that requires orders of magnitude more resources to solve algorithmically than it takes to verify the solution is a good candidate for proof of work. Ethereum uses the ”Ethash” as its Proof-of-Work.

! In the near future Ethereum is planning to switch to Proof-Of-Stake !

Ethereum Accounts

There are two types of accounts in Ethereum and understanding this distinction is essential !

  • Externally Owned Accounts :
    • Controlled by a private key, and if you own the private key associated with it, you have the ability to send ether and messages from it.
    • has an ether balance.
    • can send transactions (ether transfer or trigger contract code).
    • have no associated code.
  • Contracts Accounts
    • have an ether balance.
    • have associated code.
    • code execution is triggered by transactions or messages (calls) received from other contracts.
    • when executed; perform operations, manipulate its own persistent storage, can call other contracts ..

Gas

One of the major concepts that must be understood in Ethereum is Gas !

When a contract is executed as a result of being triggered by a message or transaction, every instruction is executed on every node of the network.

This has a cost: for every executed operation there is a specified cost, expressed in a number of gas units.

Gas is the name for the execution fee that senders of transactions need to pay for every operation made on an Ethereum blockchain. Gas is purchased for Ether from the miners that execute the code.

Gas and Ether are decoupled deliberately since units of gas align with computation units having a natural cost, while the price of Ether generally fluctuates as a result of market forces.

In other words, Gas is a unit of measuring the computational work of running transactions or smart contracts in the Ethereum network.

Different kinds of transactions require a different amount of gas to complete.

  • Gas limit refers to the maximum amount of gas we’re willing to spend on a particular transaction. A higher gas limits mean that more computational work might be done to execute the smart contract. In some cases, the actual needed Gas can be sometimes hard to estimate before actually executing the transaction. Gas limit acts as a safety mechanism to protect us from using all our funds due to buggy codes or an error in the smart contract.

  • Gas Price refers to the price in Gwei that we’re willing to pay for each unit of Gas used. Miners will “work on” and execute transactions that offer a higher gas price, as they’ll get to keep the fees. Therefore, they will be incentivized to prioritize transactions that have a higher Gwei. If we want our transaction to be executed at a faster speed, then we have to be willing to pay a higher gas price !

The actual transaction fee is calculated such that :

  • TransactionFee = GasUsedByTransaction x GasPrice

At the time of writing this post, the recommended Gas Prices in Gwei according to https://ethgasstation.info/ is depicted as follows : Gas price

This means that if we intend to execute our transaction :

  • In less than 2 minutes then fix the Gas price to 20 Gwei
  • In less than 5 minutes then fix the Gas price to 16.6 Gwei
  • In less than 30 minutes then fix the Gas price to 14 Gwei

Of course the Gas price depends on the network congestion; the more transactions we have in the network, the more gas prices increase !

Now that we’re done with the major key concepts of Ethereum, we will be able code, compile, deploy and test our first smart contract.

See you in Part2 !