0% found this document useful (0 votes)
13 views26 pages

Module 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views26 pages

Module 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

UNIT-5

Smart Contract :

Smart contracts are now an ongoing and intense area of research in the blockchain space. Many blockchains have
emerged that support smart contracts.

Due to benefits such as the increased security, cost-saving, and transparency that smart contracts can bring to many

ud
industries (especially the finance industry), rigorous research is in progress at various commercial and academic
institutions to make the implementation of smart contracts easier, more practical, business-friendly, and more secure
as soon as possible.

A smart contract is a secure and unstoppable computer program representing an agreement that is automatically
executable and enforceable.
lo
Dissecting this definition reveals that a smart contract is, fundamentally, a computer program that is written in a
language that a computer or target machine can understand. Also, it encompasses agreements between parties in the
form of business logic. Another fundamental idea is that smart contracts are automatically executed according to the
C
instruction that is coded in.

Ricardian contracts:
tu

Ricardian contracts were initially used in a bond trading and payment system called Ricardo. The fundamental idea
behind this contract is to write a document that is understood and accepted by both a court of law and computer
software. Ricardian contracts address the challenge of the issuance of value over the internet. A Ricardian contract
identifies the issuer and captures all the terms and clauses of the contract in a document to make it acceptable as a
V

legally binding contract.

A Ricardian contract is a document that has several ofthe following properties:

● It is a contract offered by an issuer to holders

● It is a valuable right held by holders and managed bythe issuer


● It can be easily read by people (like a contract on paper)

● It can be read byprograms (parsable, like a database)

● It is digitally signed

● It carries the keys and server information

● It is allied with a unique and secure identifier

ud
Smart contracts can be implemented in any industry where they are required, but the most popular use cases relate to
the financial sector. This is because blockchain first found many use cases in the finance industry and, therefore,
sparked enormous research interest in the financial industry long before other areas. Recent work in the smart contract
space specific to the financial sector has proposed the idea of smart contract templates.

Smart contracts may or may not be deployed on a blockchain, but it makes sense to do so on a blockchain due to the
securityand decentralized consensus mechanism provided by the blockchain.

The DAO
lo
The Decentralized Autonomous Organization (DAO), started in April 2016, was a smart contract written to
provide a platform for investment. Due to a bug, called the reentrancy bug, in the code, it was hacked in June 2016.
C
An equivalent of approximately 3.6 million ether (roughly 50 million US dollars) was siphoned out of the DAO into
another account.

Even though the term hacked is used here, it was not really hacked. The smart contract did what it was asked to do
tu

but due to the vulnerabilities in the smart contracts, the attacker was able to exploit it. It can be seen as an
unintentional behavior (a bug) that programmers of the DAO did not foresee. This incident resulted in a hard fork on
the Ethereum blockchain, which was introduced to recover from the attack.

The DAO attack exploited a vulnerability (reentrancy bug) in the DAO code where it was possible to withdraw
tokens from the DAO smart contract repeatedly before giving the DAO contract a chance to update.
V
Hyperledger:

Hyperledger is not a blockchain, but a project that was initiated by the Linux Foundation in December 2015 to
advance blockchain technology. This project is a collaborative effort by its members to build an open source
distributed ledger framework that can be used to develop and implement cross-industry blockchain applications and
systems. The principal focus is to create and run platforms that support global business transactions. The project also
focuses on improving the reliability and performance of blockchain systems.

ud
Projects under Hyperledger:

There are four categories of projects under Hyperledger. Under each category, there are multiple projects. The
categories are:

● Distributed ledgers


Libraries

Tools

Domain-specific
lo
C
Currently, there are six distributed ledger projects under the
Hyperledger umbrella: Fabric, Sawtooth, Iroha, Indy, Besu, and Burrow. Under libraries, there
are the Aries, Transact, Quilt, and Ursa projects. The tools category of Hyperledger includes projects such as
tu

Avalon, Cello, Caliper, and Explorer. There are also domain-specific projects such
as Hyperledger Grid and Hyperledger Labs.

Hyperledger reference architecture:


V

Hyperledger has published a white paper that presents a reference architecture model that can serve as a guideline to
build permissioned distributed ledgers. The reference architecture consists of various components that form a business
blockchain.
These high-level components are shown in the reference architecture diagram here, which has been drawn from the
aforementioned white paper:

ud
lo
C
Figure :Reference architecture
tu

In the preceding diagram, starting from the left, we see that we have five top-level components that provide various
services. The first is identity, which provides authorization, identification, and authentication services under
membership services. Then, we have the policy component, which provides policy services.
V

Hyperledger Fabric:

Hyperledger Fabric, or Fabric for short, is the contribution made initially by IBM and Digital Assets to the
Hyperledger project. This contribution aims to enable a modular, open, and flexible approach toward building
blockchain networks.
Various functions in the fabric are pluggable, and it also allows the use of any language to develop smart contracts.
This functionality is possible because it is based on container technology (Docker), which can host any language.

Chaincode is sandboxed in a secure container, which includes a secure operating system, the chaincode language,
runtime environment, and SDKs for Go, Java, and Node.js. Other languages can be supported too in the future, if
required, but this needs some development work. This ability is a compelling feature compared to domain-specific
languages in Ethereum, or the limited scripted language in Bitcoin. It is a permissioned network that aims to address
issues such as scalability, privacy,...

ud
Hyperledger Sawtooth:
Sawtooth is an enterprise-grade distributed ledger that can run in both permissioned and non-permissioned modes.
Sawtooth has several new features, which are introduced in the following sections.

Core feature: lo
These features include modular design, parallel transaction execution, global state agreement, dynamic consensus, and
some other advanced features.
C
Modular design:

The modular design of Sawtooth enables separation between the application and the core system. This means that
tu

developers can focus on the business objectives instead of worrying about the underlying design of the system. The
design of Sawtooth can be viewed as a layered architecture where transaction processors manage the application
business logic and, on another layer, validators handle the verification and consensus on transactions. A separate
layer called the transaction processing layer is responsible for managing transaction...
V

Setting up a Sawtooth development environment:

There are a few prerequisites that are required in order to set up the development environment.

The easiest wayto get Sawtooth up and running is byusing Docker. In the following example, we will set up a
5-node network using Docker.
Prerequisites

For this process, you'll need to first install Docker. In this example we are using:

ud
Sawtooth supports different consensus algorithms. In this example we will use PoET. However, other options are
available too, such as PBFT. The YAML configuration files for both of these options are available at the links in the
following sections.

Using PoET

The following link is available to download the YAML file for setting up Sawtooth with the PoET consensus

poet.yaml

Using PBFT
lo
algorithm: https://sawtooth.hyperledger.org/docs/core/nightly/1-2/app_developers_guide/sawtooth-default-
C
Here, you can access the YAML file for setting up Sawtooth with PBFT
consensus: https://sawtooth.hyperledger.org/docs/core/nightly/1-2/app_developers_guide/sawtooth-default-
pbft.yaml
tu

Setting up a Sawtooth network:

In this , Sawtooth network can be created. First we start with creating a directory and then we will download
specific configuration files, which will help with the configuration of the network.
V

● Create a directory named sawtooth:

● Change the directory to sawtooth:

● Download the PoET YAML file:


This command will show an output like the following, indicating that the sawtooth-default-poet.yaml file
has been downloaded successfully. Note that only the final part of the output is shown for brevity:

ud
...
2020-06-29 21:04:22 (51.9 KB/s) - 'sawtooth-default-poet.yaml' saved [16543/16543]

● Start the network:

lo
This will show a long output and will take several minutes to complete. The output will be similar to the following,
which shows the progress of the process:

Creating network "sawtooth_default" with the default driver


C
Creating volume "sawtooth_poet-shared" with default driver
tu
V
The Sawtooth Lake Distributed Ledger :

It is a software framework for constructing decentralized ledgers with extensible transaction types. It is comparable to
the blockchain ledger that underlies Bitcoin. Sawtooth Lake uses a unique mechanism for reaching consensus on the
validity of the ledger based on trusted code running inside a hardware-protected Intel Software Guard Extensions
(SGX) enclave.

One of the initial transaction families supported by Sawtooth Lake is the MarketPlace. The MarketPlace Transaction

ud
Family establishes the concepts of participants, accounts, assets, holdings, liabilities, and offers in a decentralized
ledger to facilitate the exchange of digital assets. The Sawtooth Lake architecture allows the definition of additional
transaction families or the consumption of an existing asset-type agnostic transaction family (like MarketPlace) to
meet domain-specific needs.

sawtooth-core: lo
Contains fundamental classes used throughout the Sawtooth Lake project, as well as:

● The gossip networking layer


C
● Basic transaction, block, and message objects
● The base journal implementation
● The PoET journal consensus mechanism
tu

● Built-in transaction families - Endpoint Registry and Integer Key Registry


● The implementation ofa server, known as the validator
o acts as a node on the gossip network
o validators exchange and act upon messages, as defined by the core classes and via additional
plug-in transaction families like the MarketPlace Transaction Family
V

● The MarketPlace Transaction Family, located in the extensions directory.


o demonstrates how to inherit and extend base sawtooth-core object types to implement a custom
transaction family
o includes a command line interface called mktclient for interacting with validators running the
MarketPlace Transaction Family
o useful for buying, selling and trading digital assets
● Example code, in the form of games, which demonstrate keyconcepts of Sawtooth Lake
● Tools including a Vagrant environment for easily launching a network ofvalidators
● Source files for this documentation

Core Architecture:
The Sawtooth Lake Distributed Ledger consists of three major architectural layers: the Ledger layer, the Journal
layer, and the Communication Layer.

ud
Ledgers:
Ledgers are a conceptual semantic and data model layer for transaction types. Ledgers are described as a ‘conceptual’
layer because they are implemented as a specialization of existing base classes already present in the Communication
and Journal layers.

In addition to some in-built system ledgers (Endpoint Registry, and Integer Key Registry), implementing new classes
lo
in the ledger layer allows for the creation of new transaction families. The MarketPlace Transaction Family, located in
the extensions directory of sawtooth-core, is a good example of how the ledger layer can be extended.

Journals
C
A journal handles consensus on blocks of identifiers. Identifiers reference transactions, which are globally replicated.
In order to confirm blocks, nodes need a copy of the transaction. In this fashion, the journal provides global
consensus on block ordering, transaction ordering within blocks, and the content of transactions.
tu

The journal module in sawtooth-core contains:

● The Implementation Of The Base Transaction And Transaction Block Classes


● The Consensus Algorithms
V

● The Global Store Manager


● The Block Store And Key Value Store

The consensus journal object is journal.journal_core.Journal in the sawtooth-core repository.

Consensus Mechanisms:
Sawtooth Lake implements PoET as a consensus mechanism.

PoET and SGX:

The Sawtooth Lake Distributed Ledger provides a unique mechanism to ensure fairness in the node lottery. Instead of
a Proof-of-Work competition amongst nodes, Sawtooth Lake implements a Proof-of-Elapsed-Time (PoET) algorithm
for distributed consensus. PoET relies upon a trusted execution environment, Intel’s Software Guard Extensions

ud
(SGX), to generate fair, verifiable random wait timers and signed certificates of timer expiration. This mechanism
substantially reduces the computation and energy cost of ensuring fair distributed consensus.

The implementation of PoET in Sawtooth Lake runs in a simulated enclave, not a true trusted execution environment.
For this reason, attestation that wait timers have been fairly generated is not possible. This version of PoET is

lo
intended for experimental purposes and should not be used as the consensus mechanism in any ‘production’
environment.
C
tu
V
UNIT-4

ETHEREUM :
Ethereum is a platform powered by blockchain technology that is best known for its native cryptocurrency, called
ether, or ETH, or simply ethereum. The distributed nature of blockchain technology is what makes the Ethereum
platform secure, and that security enables ETH to accrue value.

ud
Ethereum, just like any other blockchain, can be visualized as a transaction-based state machine. The idea is that a
genesis state is transformed into a final state by executing transactions incrementally. The final transformation is then
accepted as the absolute undisputed version of the state. In the following diagram, the Ethereum state transition
function is shown, where a transaction execution has resulted in a state transition.

Elements of Ethereum Block chain: lo


In the following section, you will be introduced to various components of the Ethereum network and the blockchain.
First, the basic concept of the EVM is givenin the next section.
C
Ethereum virtual machine(EVM)
EVM is a simple stack-based execution machine that runs bytecode instructions in order to transform the system state
from one state to another. The word size of the virtual machine is set to 256-bit. The stack size is limited to 1024
tu

elements and is based on the LIFO (Last in First Out) queue. EVM is a Turing-complete machine but is limited by
the amount of gas that is required to runany instruction. This means that infinite loops that can result in denial of
service attacks are not possible due to gas requirements.

EVM also supports exception handling in case exceptions occur, such as not having enough gas or invalid
V

instructions, in which case the machine would immediately halt and return the error to the executing agent.EVM is a
fully isolated and sandboxed runtime environment. EVM is a stack-based architecture.EVM is big-endian by design
and it uses 256-bit wide words. This word size allows for Keccak 256-bit hash and elliptic curve cryptography
computations.
EVM also supports exception handling in case exceptions occur, such as not having enough gas or invalid
instructions, in which case the machine would immediately halt and return the error to the executing agent.EVM is a
fully isolated and sandboxed runtime environment.
As discussed earlier, EVM is a stack-based architecture. EVM is big-endian by design and it uses 256-bit wide words.
This word size allows for Keccak 256-bit hash and elliptic curve cryptography computations.

The following diagram shows the design of the EVM where the virtual ROM stores the program code that is copied

ud
into main memory using CODECOPY. The main memory is then read by the EVM by referring to the program
counter and executes instructions

lo
C
tu

EVM operation

EVM optimization is an active area of research and recent research has suggested that EVM can be optimized and
tuned to a very fine degree in order toachieve high performance. Research into the possibility of using Web assembly
V

(WASM) is underwayalready. WASM is developed by Google, Mozilla, and Microsoft and is now being designed as
an open standard by the W3C community group. The aim of WASM is to be able to run machine code in the browser
that will result in execution at native speed. Similarly, theaim of EVM 2.0 is to be able to run the EVM instructionset
(Opcodes) natively in CPUs, thus making it faster and efficient.
PRE-COMPILED CONTRACTS:

There arefour precompiled contracts in Ethereum. Hereis the list of these contracts and details. The
elliptic curve public key recovery function

ECDSARECOVER (Elliptic curve DSA recover function) is available at address 1. It is denoted as ECREC and
requires 3000 gas for execution. If the signature is invalid, then no output is returned by this function. Public key

ud
recovery is a standard mechanism by which the public key can be derived from the privatekey in elliptic curve
cryptography.
The ECDSA recovery function is shown as follows:

ECDSARECOVER(H, V, R, S) = Public Key

lo
It takes four inputs: H, which is a 32 byte hash of the message to be signed and V, R, and S, which represent the
ECDSA signature with the recovery ID and produce a64 byte public key. V, R, and S have been discussed in detail
previously in this chapter.
C
The SHA-256 bit hash function
The SHA-256 bit hash function isa precompiled
contract that is available at address 2 and produces a SHA256 hash of the input. It is almost like a pass - through
tu

function. Gas requirement for SHA-256 (SHA256) depends on the input data size. The output is a 32 bytevalue.

The RIPEMD-160 bit hashfunction


The RIPEMD-160 bit hash function is used to provide RIPEMD 160 -bit hash and is available at address 3. Theoutput
of this function is a 20-byte value. Gas requirement, similar to SHA-256, is dependent on the amount ofinput data.
V

The identity function:

The identity function is available at address 4 and is denoted by the ID. It simply defines output as input; in
other words, whatever input is given to the ID function, it will output the same value. Gas requirement is calculated by
a simple formula: 15 + 3 [Id/32] where Id is the input data. This means that at a high level, the gas requirement is
dependent on the size of the input data albeit with some calculation performed, as shown in the preceding equation.All
the previously mentioned precompiled contracts canbecome native extensions and can be included in the EVM
opcodes in the future.

ACCOUNTS AND ITS TYPES :

ud
Accounts are one of the main building blocks of the Ethereum blockchain. The state is created or updated asa result of
the interaction between accounts. Operations performed between and on the accounts represent state transitions. State
transition is achieved using what's called the Ethereum state transition function, which works as follows:
1. Confirm the transaction validity by checking the syntax, signaturevalidity, and nonce.
2. Transaction fee is calculated and the sending address is resolved using the signature. Furthermore, sender's

account balance is not enough.


lo
account balance is checked and subtracted accordingly and nonce is incremented. Anerror is returned if the

3. Provide enough ether (gas price) to cover the cost of the transaction. This is charged per byte incrementally
according to the size of the transaction.
C
4. In this step, the actual transfer of value occurs. The flow is from the sender's account to receiver's account.
The account is created automatically if the destination account specified in the transaction does not exist yet. if
the destination account is a contract, then the contract code is executed. If enough gas is available, then the
tu

contract code willbe executed fully; otherwise, it will run up to the point where it runs out ofgas.
5. In cases of transaction failure due to insufficient account balance orgas, all state changes are rolled back with
the exception of fee payment, which is paid to the miners.
6. Finally, the remainder (if any) of the fee is sent back to the sender as change and fee is paid to the miners
accordingly. At this point, thefunction returns the resulting state.
V
TYPES OF ACCOUNTS : There are two types of accounts in Ethereum:

• Externally owned contacts


• Contract accounts

The first is externally owned accounts (EOAs) and the other is contract accounts. EOAs are similar to accountsthat
are controlled by a private key in bitcoin. Contract accounts are the accounts that have code associated with them

ud
along with the private key. An EOA has ether balance, is able to send transactions, and has no associated code,
whereas a Contract Account (CA) has ether balance, associated code, and the ability to get triggered and execute
code in response to a transaction or a message that due to the Turing - completeness property of the Ethereum
blockchain, the code within contract accounts can be of any level of complexity. The code is executed by EVM by
each mining node on the Ethereum network. In addition, contract accounts are able to maintain their own permanent
state and can call oth er contracts. It is envisaged that in the serenity release, the distinction between externally owned

lo
accounts and contract accounts may be eliminated.

Block:
As discussed earlier, blocks are the main building blocksof a blockchain. Ethereum blocks consist of various components,
C
which are described as follows:
• The block header
• The transactions list
tu

• The list of headers of ommers or uncles

The transaction list is simply a list of all transactions included in the block. In addition, the list of headers of Unclesisalso
included inthe block. The most important and complex part is the block header.

BLOCK HEADER
V

Block headers are the most critical and detailed components of an Ethereum block. The header contains
valuableinformation, which is described in detail here.
PARENT HASH
This is the Keccak 256-bit hash of the parent (previous)block's header.
OMMERS HASH
This is the Keccak 256-bit hash ofthe list of Ommers (Uncles) blocks included in the block.

BENEFICIARY
Beneficiary field contains the 160-bit address of the recipient that will receive the mining reward once theblock is
successfully mined.
STATE ROOT
The state root field contains the Keccak 256-bit hash ofthe root node of the state trie. It is calculated after all

ud
transactions have been processed and finalized.

TRANSACTIONS ROOT
The transaction root is the Keccak 256 -bit hash of the root node of the transaction trie. Transaction trie representsthe
list of transactions included in the block.

RECEIPTS ROOT
lo
The receipts root is the keccak 256 bit hash of the root node of the transaction receipt trie. This trie is composedof
receipts of all transactions included in the block.
Transaction receipts are generated after each transaction is processed and contain u seful post- transaction
C
information. More details on transactionreceipts.

LOGS BLOOM
tu

The logs bloom is a bloom filter that is composed of the logger address and log topics from the log entry of
eachtransaction receipt of the included transaction list in the block. Logging is explained in detail in the next section.

DIFFICULTY
The difficulty level of the current block.
V

NUMBER
Thetotal number ofall previous blocks; the genesisblock is block zero.
GAS LIMIT: The field contains the value that represents the limit setonthe gas consumption per block.

GAS USED: The field contains the total gas consumed by thetransactions included in the block.

TIMESTAMP : Timestamp is the epoch Unix time of the time of blockinitialization.

ud
EXTRA DATA: Extra data field can be used to store arbitrary datarelated to the block.

MIXHASH:
Mixhash field contains a 256-bit hash that once combined with the nonce is used to prove that adequate
computational effort has been spent in order to create this block.

NONCE
lo
Nonce is a 64-bit hash (a number) that is used to prove, in combination with the mixhash field, that adequate
computational effort has been spent in order to create this block.
C
The following figure shows the detailed structure oftheblock and block header:
tu
V
Detailed diagram of block structure with block
header
ETHER:

Ether is minted by miners as a currency reward for the computational effort they spend in order to secure the network
by verifying and with validation transactions andblocks. Ether is used within the Ethereum blockchain to pay for the
execution of contracts on the EVM. Ether is used to purchase gas as crypto fuel, which is required inorder to perform
computation on the Ethereum blockchain.

ud
The denominationtable is shown as follows:

lo
C
Feesare charged for each computation performed bythe EVM on the blockchain.

Gas
tu

Gas is required to be paid for every operation performedon the ethereum blockchain. This is a mechanism that ensures
that infinite loops cannot cause the whole blockchain to stall due to the Turing-complete nature of the EVM.A fee is
paid for transactions to be included by miners for mining. If this fee is too low, the transaction may never be picked
up; the more the fee,the higher are the chances that the transactions will bepicked up bythe miners for inclusion in the
block.
V

Conversely, if the transaction that has an appropriate feepaid is included in the block by miners but has too many
complex operations to perform, it can result in an out-of- gas exception if the gas cost is not enough. In this case, the
transaction will fail but will still be made part of the block and the transaction originator will not get anyrefund.
Transaction cost can be estimated usingthe followingformula:

Totalcost = gasUsed * gasPrice


Here, gasUsed is the total gas that is supposed to be used by the transaction during the execution.This is specified in
Ether. Each EVM opcode has a fee assigned to it. It is an estimate because the gas used can be more or less than the
value specified bythe transaction originator originally.
• For example, if computation takes too long or the behavior of the smart contract changes in response to some

ud
other factors, thenthe transaction execution may perform more or less operations than originally intended and
can result in consuming more or fewer gas.

Each operation costs some gas; a high level fee schedule of a few operations is shown as an examplehere:

lo
C
tu

Based on the preceding fee schedule and the formuladiscussed earlier, an example calculation of the SHA3 operation can
be calculated as follows:
• SHA3 costs 30 gas
• Current gas price is 25 GWei, which is 0.000000025
V

• EtherMultiplying both: 0.000000025 * 30 = 0.00000075

Ether In total, 0.00000075 Ether is the total gas that will becharged.
Fee schedule
Gas is charged in three scenarios as a prerequisite tothe execution ofan operation:
• The computation of an operation
• For contract creation or message call
• Increase in the usage of memory

A list of instructions and various operations with the gasvalues has been provided.

MESSAGES:
• Messages, as defined in the yellow paper, are the dataand value that are passed between two accounts. A
message is a data packet passed between two accounts. This data packet contains data and value (amount of
ether).

ud
• Contracts can send messages to other contracts. Messages only exist in the execution environment and are
never stored. Messages are similar to transactions; however, the main difference is that they are produced by
the contracts, whereas transactions are produced by entities external to the Ethereum environment.

A message consists of the components mentioned here:


• Sender of the message




Recipient of the message
lo
Amount of Wei to transfer and message to the contract address
Optional data field (Input data for the contract)
Maximum amount of gas that can be consumed
C
Messages are generated when CALLor DELEGATECALLOpcodes are executed by the contracts.
tu

MINING:

Mining is the process by which new currency is added tothe blockchain. This is an incentive for the miners to validate
and verify blocks made up of transactions. The mining process helps secure the network by verifying computations.
V

At a theoretical level, a miner performs the followingfunctions:


• Listens for the transactions broadcasted on the Ethereum networkand determines the transactions to be
processed.
• Determines stale blocks called Uncles or Ommers and includes themin the block.
• Updates the account balance withthe reward earned fromsuccessfully mining the block.
• Finally, a valid state is computed and block is finalized, which definesthe result of all statetransition.

The current method of mining is based on Proof of Work, which is similar to that of bitcoin,but it must also contain
the Proof of Work for a given difficulty.
Considerable research work has been carried out in order to build the Proof of Stake algorithm suitable for the
Ethereum Network.
various methods of mining are mentioned.

ud
CPU mining
Even though not profitable on the main net, CPU miningis still valuable on the test network or even a private network
to experiment with mining and contract deployment. Private and test networks will be discussedwith practical
examples in the next chapter. A geth example is shown on how to start CPU mining here.
Geth can be started with mine switch in order to startmining:

geth --mine --minerthreads<n>


lo
CPU mining can also be started using the web 3 geth console. Geth console can be started by issuing the following
command:
C
After this, the miner can be started by issuing the following command, which will return true if successful, or false
otherwise. Take a look at the following command:
tu

The preceding command will start the miner with fourthreads. Take a look at the following command:
V
The preceding command will stop the miner. The command will return true if successful.

GPU mining
At a basic level, GPU mining can be performed easily byrunning two commands:

ud
Once geth is up and running and the blockchain is fully downloaded, Ethminer can be run in order to start mining.
Ethminer is a standalone miner that can also beused in the farm mode to contribute to mining pools. It can be
downloaded from https://github.com/Genoil/cpp-ethereum/tree/master/releases:

Mining rigs
lo
Mining rigs can be built with some effort and are also available commercially from various vendors. A typical
mining rig configuration includes the components discussed in the upcoming sections.
C
MOTHERBOARD
A specialized motherboard with multiple PCI-E x1 or x16 slots, for example, BIOSTAR Hi-Fi or ASRock H81,
is required
SSD HARD DRIVE
tu

An SSD hard drive is required. The SSD drive is recommended because of its much faster performanceover theanalog
equivalent. This will be mainly usedto store the blockchain.
GPU
The GPU is the most important component of the rig as itis the main workhorse that will be used for mining. For
V

example, it can be a Sapphire AMD Radeon R9 380 with4 GB RAM


Mining pools
There are many online mining pools that offer Ethereummining. Ethminer can be used to connect to a mining pool
using the following command. Each pool publishes its own instructions, but generally, the process of connecting to
a pool is similar.
TRADING AND INVESTMENT:

Etheris available at various exchanges for buying andselling. The current market cap of Ethereum is
£680,277,967 at the time of writing this, and an Ether isworth £7.89. Recently, the price has been very volatile and has
dropped down significantly due to recent Ethereum attacks and subsequent forks on the Ethereum network.
The following chart shows the historical marketcapitalization details:

ud
lo
C
Ether historical market capitalization (source Etherscan.io).There are online services available, such as shapeshift.io,
tu

that allow conversion from one currency to another.Various online exchanges, such as kraken, coinbase, and many
more, offer ether to be purchased for fiat currency using credit cards or another virtual currency,such as bitcoin.

THE YELLOW PAPER


V

The Ethereum yellow paper has been written by Dr. Gavin Wood and serves as a formal definition of the Ethereum
protocol. Anyone can implement an Ethereum client by following the protocol specifications defined in the paper.
This paper can be somewhat difficult to read, especially for the readers who do not have a backgroundin algebra or
mathematics and are not familiar with mathematical notations.
Once symbol meanings are known, it becomes quite easy to understand and appreciate the concepts and
specifications described inthe yellow paper.

THE ETHEREUM NETWORK:

The Ethereum network is a peer-to-peer network where nodes participate in order to maintain the blockchain
andcontribute to the consensus mechanism. Networks can be divided into three types, based on requirements and

ud
usage.
MainNet : MainNet is the current live network of ethereum. Thecurrent version of MainNet is homestead. TestNet
: TestNet is also called Ropsten and is the test network forthe Ethereum blockchain. This blockchain is used to test
smart contracts and DApps before being deployed to theproduction live blockchain. Moreover, being a test network,
it allows experimentation and research.
Private net(s):
lo
As the name suggests, this is the private network that can be created by generating a new genesis block. This is
usually the case in distributed ledger networks, wherea private group of entities start their own blockchain
Supporting protocols:
C
There are various supporting protocols that are in development in order to support the complete
decentralized ecosystem. This includes whisper and Swarm protocol.
Whisper
tu

Whisper provides decentralized peer-to-peer messaging capabilities to the ethereum network. In essence, whisper is
a communication protocol that nodes use inorder to communicate with each other.
SWARM
Swarm is being developed as a distributed file storage platform. It is a decentralized, distributed, and peer-to- peer
storage network. Files in this network are addressed by the hash of their content
V
APPLICATIONS DEVELOPED ON ETHEREUM:

There are various implementations of DAOs and smart contracts in Ethereum, most notably, the DAO, which was
recently hacked and required a hard fork in order for funds to be recovered. The DAO was created to serve asa
decentralized platform to collect and distribute investments.

Augur is another DAPP that has been implemented onEthereum, which is a decentralized prediction market. Various

ud
other decentralized applications are listed on http://dapps.ethercasts.com/.

SCALABILITY AND SECURITY ISSUES:


Scalability in any blockchain is a fundamental issue. Security is also of paramount importance. Issues such as privacy
and confidentiality have caused some adaptability issues, especially in the financial sector. However, a great deal of

lo
research is being conducted in these areas. Even though various use cases and proof of concept systems have been
developed and the technology works well for many of the scenarios, there still is a need to address some fundamental
limitations that are present in blockchains in order to make this technology more adaptable.
C
At the top of the list of these issues comes scalability and then privacy. Both of these are important limitations to
address, especially as blockchains are envisioned to be used in privacy-demanding industries too. There are specific
requirements around confidentiality of transactions in finance, law and health, whereas scalability is generally a
concern where blockchains do not meet the adequate performance levels expected by the users. These two issues are
tu

becoming inhibiting factors toward blockchain technology's wider acceptance.

Scalability:

This is the single most important problem that could mean the difference between wider adaptability of blockchains or
V

limited private use only by consortiums. As a result of substantial research in this area, many solutions have been
proposed from a theoretical perspective, the general approach toward tackling the scalability issue generally revolves
around protocol-level enhancements. For example, a commonly mentioned solution to bitcoin scalability is to increase
its block size. Other proposals include off-chain solutions that offload certain processing to off-chain networks, for
example, off-chain state networks. Based on the solutions mentioned
above, generally, the proposals can be divided into two categories: on-chain solutions that are based on the idea
ofchanging fundamental protocols on which the blockchain operates.

Privacy:

Privacy of transactions is a much desired property of blockchains. However, due to its very nature, especially in
public blockchains, everything is transparent, thus inhibiting its usage in various industries where privacy is of
paramount importance, such as finance, health, and many others. There are different proposals made to address the

ud
privacy issue and some progress has already been made. Several techniques, such as indistinguishability obfuscation,
usage of homomorphic encryption, zero knowledge proofs, and ring signatures.

Security:

Even though blockchains are generally secure and make use of asymmetric and symmetric cryptography as required

blockchain.
lo
throughout the blockchain network, there still are few caveats that can result in compromising the securityof the

There are a few examples of transaction malleability, eclipse attacks, and possibility of double spending in bitcoin
C
that, in certain scenarios, have been shown to work by various researchers.
tu
V

You might also like