Ethereum, The A B C.

Verify.as
verifyas
Published in
5 min readOct 14, 2017

This is the fourth in a series of posts where we discuss the core concepts behind the Blockchain, Bitcoin and Ethereum. At Verify, we’re building a reputation protocol on the Ethereum blockchain and are sharing these posts in an effort to share our knowledge with the wider crypto community.

Ethereum is a fictional element. It is currently known as an open source blockchain-based distributed computing platform. Its founder is Vitalik Buterin and he chose the name Ethereum because it had the word ether in it, the “hypothetical invisible medium that permeates the universe and allows light to travel” (you can see Vitalik response to choice of name here)

I just mentioned “blockchain-based”; does this mean it is similar to Bitcoin? Yes, it is a blockchain, with one extra important feature and that is a built-in Turing-complete programming language. A turing-complete language, in layman’s terms, is a language that allows you to run any program you write it with; i.e. you can write any algorithm and will be able to execute it. For example, a calculator (be it scientific or normal) is not turing complete; a computer that allows programming is.

The turing complete programming language in Ethereum allows anyone to write code over the blockchain; that code is known as a “smart contract”. This means it allows you to create decentralized applications that can have their own transition functions, formats as well as ownership rules. It is basically Bitcoin with a programming language and that is the major conceptual difference between Ethereum and Bitcoin.

Ethereum Accounts:

Let us explore other differences between the two. In previous posts we talked about Bitcoin’s states and transition and how a transaction is executed. The state in Bitcoin is basically a collection of UTXOs; in Ethereum, the state is made up of objects called “accounts”. Each account has a 20 byte address. In Bitcoin, the state transition was a transfer from a state to another state. In Ethereum, the state transition is direct transfer between accounts.

An ethereum account contains:

- nonce: counters to make sure that each transaction can only be processed once (we will explore this in another post).
-
ether balance (crypto fuel of ethereum)
-
contract code (optional)
-
storage (empty by default)

Accounts can be divided to two types: normal accounts known as externally owned accounts and contract accounts.

Externally owned accounts are controlled by a private key, it has no code, and one can send signed transactions from it.

Contract accounts are controlled by their contract code. They contain code and they are executed whenever they receive messages or transactions and accordingly access the storage of type key/value) and/or create other contracts. Contracts control their own ether balance and their storage (of type key/value). Ether is the crypto fuel; for simplicity, think of it as the currency in Ethereum. Contracts live on the blockchain in a byte code format (don’t worry there are high level languages to write them; byte code is just the way they are compiled).

I’ve just mentioned the terms messages and transactions; in several other resources out there, messages and transaction are used interchangeably; however there is an important distinction:

Transactions in ethereum are the signed data packages that contain a message from an externally owned account and they are registered in the blockchain. Note the word “signed”, because that is one critical aspect of a transaction. A transaction contains:

- some important identification fields, like:

- The recipient of the message.
- A signature identifying the sender.
- The amount of ether to transfer from sender to recipient.
- Data field (optional) hold any data to send to contract.
- STARTGAS value, think of it as the quantity of gas that the sender is willing to consume on this entire transaction.
- GASPRICE, represents the fee the sender pays per computational step (n of list).

Note: gas in ethereum is the computational unit; usually one computational step costs 1 gas. Also keep in mind that 1 byte in the transaction data field costs 5 gas. Gas prices are usually charged in Gwei. 1 ether = 10⁹ Gwei. Gwei = 10⁹ wei. Gas prices usually vary amongst miners.

We have seen in Bitcoin how the network is focused on executing one type of application and that is the transfer of coins. In Ethereum, different types of applications can be built since it has a programming language; the processing power required to execute transactions in Ethereum would vary greatly amongst the many different applications that are built; there can be complex transactions and simple ones. Complex transactions would be more expensive to execute since they require more computing power; simpler transactions would be cheaper. That is why we have a STARTGAS and GASPRICE for each transaction. At the start of execution, STARTGAS would be multiplied by GASPRICE and the total would be the number ether to remove from the sender’s account. Each transaction should have a limit on the number of computational steps are required to execute code. STARTGAS and GASPRICE are important because they help prevent any wastage or infinite loops. The reason we have a STARTGAS and GASPRICE (as opposed to a single metric like “ETHLIMIT”) is because gas is measured in ETH, and ETH’s price fluctuates vs. USD (but that has nothing to do with the actual cost of executing the program). By separating the two, a miner could simply sort the pending transactions by GASPRICE (from highest to lowest) and give execution priority to the transactions that are offering more ETH per unit gas (i.e. a higher GASPRICE). To find out what’s the appropriate GASPRICE to use, check out http://ethgasstation.info/ .

Note: The assigned gas value in a transaction or contract applies to all execution, including subs. For example, A sends B a transaction with 100 gas. B consumes 30 gas and sends a message to C and C uses 50 gas now B is left with only 20 gas.

Also note that the gas used is awarded to the miner executing your transaction(s). Miners are free to choose which transaction to include in the block. The GASPRICE motivates them to add your transactions in the block. Miners can randomly select transactions but most follow a strategy where they list transactions from highest GASPRICE to lowest (or to the lowest value they are willing to take). If urgency is not what you are after; you can set a GASPRICE sufficient enough and wait until your are added to the block. Most users are advised to lower their GASPRICE, the idea being that by lowering the the GASPRICE, it is more likely that miners will in turn lower their charges.

Now what about Messages?

Messages are basically virtual objects that are never serialized and only exist in the Ethereum execution environment. They are sent between contracts.

A message contains:

- the sender of the message.
- the recipient of the message.
- the amount of ether to transfer alongside the message.
- an optional data field; and
- a STARTGAS value.

It is very much like a transaction except it originates from a contract not an externally owned account. This allows contracts to communicate together. The message is produced by the command (opcode) CALL .

Now those are the building blocks of Ethereum; in the next post we will look into how a transaction actually takes place? Stay tuned.

--

--