Ethereum Blockchain For Beginners - It's Structure And Operations.

Do repost and rate:

As we all know that the Bitcoin Blockchain is the mother of all the blockchains. It's purpose was to intend peer to peer transfer of value. Around 2013, some sort of code execution framework was introduced by Ethereum Founders, The centerpiece and thrust of this Ethereum blockchain is a smart contract.

Ethereum Blockchain

 

The Ethereum Blockchains took a major step towards transforming the blockchain into a computational framework that opened up a whole world of opportunities in the decentralized realm.

Ethereum supports smart contracts and a virtual machine on which these smart contracts execute.

The Smart Contracts enabled decentralized application that accomplished more than a transfer of value.

Since, Smart contracts are pretty much important when it comes to Ethereum Blockchain. Let's talk some more about Smart Contracts.

Smart Contracts

 

A Smart contract is a piece of code that are deployed in the blockchain node. The executions that are done in the smart contracts are initiated as a message and is embedded into the transaction.

As we know, some the simple digital currency transfer will have the value and some information of the sender and receiver. In Ethereum, it enables transactions that may carry out more sophisticated operations.

  • For Example, a transaction could require a conditional transfer or it may need some more signatures for transfer of assets, or it also may involve waiting for a specific time and date.
  • Let's take an example for what Smart Contracts can do, Consider a Auction bidding system. If the age of a bidder is greater than 18 and the bid is greater than the minimum bid, then accept the bid, or else reject the bid. These things or the conditions can be easily done by a Smart Contract.

How do we write a smart contract?

The smart contracts are written using basic programming language which resembles a class definition in an object oriented design like java or C++, it has data, functions with modifiers and specifiers like public or private along with getter and setter functions.

There are some specific programming languages that are designed for coding smart contracts. Solidity is one example.

  • A simple Solidity program will contain the Solidity version as a header ex. pragma solidity ^0.4.0;
  • Contract definitions like the name of the contract and the variable declarations with the type. 

ex, contract myContract {     // myContract is the name of the contract

                                                 uint storedData;  /* This is declared variable of type uint, uint is a data type that stores 32- bit unsigned integer */

                                                           }                         

  • Then at last two functions are defined for writing and reading the data i.e. Set and Get

Set, ex. function set(uint a) {

                                             storedData=x;  /* a simple set function which assigns value of x to storedData */

                                             }

Get, ex. function get() constant returns (uint) {

                                                                                      return storedData; } }  // A simple get function which reads the data stored in storedData 

So, this is a simple illustration of a basic code of smart contract, I will try to write more about these smart contracts and its coding with solidity in my future posts.

Each Ethereum node in the network should be able to execute the code irrespective of what operating systems they use. For this, there is EVM i.e. Ethereum Virtual Machine, it provides run anywhere layer for the contract.

A Smart Contract which is written in high level programming language is converted to EVM byte code and then its deployed on the Ethereum network.

Structure Of Ethereum

 

Ethereum Block structure has,

  • A header.
  • Transactions.
  • And Runner-Up Block Headers.

You can visit here to check the Ethereum blocks.

There are two types of accounts in this,

  • Externally Owned Accounts i.e. EOA, they are simple ETH accounts controlled by private keys
  • Contract Accounts i.e. CA, these are controlled by the code and can be activated only by EOA.

An EOA is needed to participate in the Ethereum network, it interacts with the Blockchain using transactions.

A CA represents a Smart Contract.

Every account has a coin balance, the participant node can send transaction for ETH transfer or it can send transaction to invoke a Smart Contract code or both.

Every type of transaction requires fees. An account must have sufficient balance to meet the fees which is needed for the transaction.

Fees are paid in Wei, 1 Ether= 10^18 Wei or 1 Wei= 0.000000000000000001 Ether.

A transaction in Ethereum includes,

  • The Recipient of the message.
  • Digital signature of the sender authorizing the transfer.
  • Amount of Wei to transfer.
  • An optional message to a Contract.
  • STARTGAS : it is the value representing the maximum number of computational steps the transaction is allowed.
  • GASPRICE : it is the value of representing the fee which sender is willing to pay for the computations.

The Smart Contract execution incurs fees, the amount available is specified by the various gas fields.

Ethereum Operations

 

In an simple Ether transfer the amount to transfer and the target address are specified along with the fees or the gas points.

For Ex, Lets assume a transaction where a Sender wants to send 100 Ether to the Receiver.

With this transaction, 2100 gas fees are paid to the miner who added the transaction block to the blockchain.

A full Ethereum node holds the software needed for,

  • Transaction initiation.
  • Validation.
  • Mining.
  • Block Creation.
  • Smart Contract execution.
  • And the EVM i.e. Ethereum Virtual Machine.

Smart Contract is designed, developed, compiled and deployed on the EVM. There can be more than one Smart Contract in an EVM.

When a target address in a transaction is a Smart Contract, the execution code corresponding to the Smart Contract is executed on the EVM. The input needed for the execution is extracted from the payload field of the transaction.

Results of the execution is told in Receipts. A blockchain maintains both state hash and the receipt hash.

All the transactions are validated. Miner nodes in the network receive, gather and execute transactions, then the validated transactions are broadcasted and gathered for block creation.

Every action in Ethereum requires crypto fuel or gas. If the fees specified in gas points in the transaction are insufficient then the transaction is rejected.

Gas related with block has,

  • GASLIMIT = amount of gas points available for a block to spend.

Ex. If a GASLIMIT is 1,500,000 Units

and the basic Ether transaction fee is 21000

Then, this Eth block can fit around 70 plain Eth transaction, if we add Smart Contract which needs more gas resulting in low number of transactions.

  • Next is GASSPENT = actual amount of gas spent at the completion of a block creation.

 

To conclude, I will point out some important points from this post,

  • Smart Contracts allow for execution of code which enhances the basic features of bitcoin blockchain.
  • Code in Smart Contracts are written in a high level language like Solidity then compiled to form a byte code and is executed on EVM.
  • There are two types of accounts in an Ethereum protocol, Externally owned accounts (EOA) and Contract Account (CA).
  • Ethereum transactions also includes messages to invoke Smart Contracts
  • Transfer of Ethers requires fees or gas points to be specified in the transaction.
  • Miners are paid fees for security, validation, execution of smart contracts as well as creation of blocks.

 

Hope you Liked it!

Please leave a like and tip if you liked the post.

 

THANK YOU.

 

Note

All the images used in this are copyright free and is from https://www.flickr.com/

Regulation and Society adoption

Ждем новостей

Нет новых страниц

Следующая новость