Unit1 SCSA1615 SmartContract Final
Unit1 SCSA1615 SmartContract Final
What is Ethereum?
Ethereum is a blockchain-based distributed platform. The network currency of Ethereum is
known as Ether (ETH). Here also, the transactions are stored in an immutable distributed
ledger. Ethereum is a Blockchain network that introduced a built-in Turing-complete
programming language that can be used for creating various decentralized applications (also
called Dapps).
Ethereum is a modular and programmable blockchain that handles applications without relying
on a centralised counterparty. The platform is built on the public, open-source, decentralised
and cryptographic blockchain technology. It powers decentralized applications (dApps) that
are supported by smart contracts. With its collective computing power on the distributed
network (the Ethereum Virtual Machine), Ethereum executes peer-to-peer transactions to
realise automatic, conditional transfer of value and information, including money, voting
rights, and property.
Ethereum is designed to be scalable, decentralized, and programmable.
It provides a flexible platform to build applications using the solidity scripting
language.
Transactions are sent and received in user created Ethereum accounts.
It is a blockchain-based platform with the cryptocurrency Ether (ETH).
The Ethereum network is currently famous for allowing the implementation of smart
contracts. Smart contracts can be thought of as ‘cryptographic bank lockers’ which
contain certain values.
These cryptographic lockers can only be unlocked when certain conditions are met.
Unlike bitcoin, Ethereum is a network that can be applied to various other sectors.
1
Ethereum is often called Blockchain 2.0 since it proved the potential of blockchain
technology beyond the financial sector.
2
How Does Ethereum Work?
Ethereum implements an execution environment called Ethereum Virtual Machine (EVM).
When a transaction triggers a smart contract all the nodes of the network will execute
every instruction.
All the nodes will run The EVM as part of the block verification, where the nodes will
go through the transactions listed in the block and runs the code as triggered by the
transaction in the EVM.
All the nodes on the network must perform the same calculations for keeping their
ledgers in sync.
Features of Ethereum
1. Smart contracts: Ethereum allows the creation and deployment of smart contracts.
Smart contracts are created mainly using a programming language called solidity.
Solidity is an Object-Oriented Programming language that is comparatively easy to learn.
2. Ethereum Virtual Machine (EVM): It is designed to operate as a runtime environment
for compiling and deploying Ethereum-based smart contracts.
3. Ether: Ether is the cryptocurrency of the Ethereum network. It is the only acceptable
form of payment for transaction fees on the Ethereum network.
4. Decentralized applications (Daaps): Dapp has its backend code running on a
decentralized peer-to-peer network. It can have a frontend and user interface written in
any language to make calls and query data from its backend. They operate on Ethereum
and perform the same function irrespective of the environment in which they get
executed.
5. Decentralized autonomous organizations (DAOs): It is a decentralized organization
that works in a democratic and decentralized fashion. DAO relies on smart contracts for
decision-making or decentralized voting systems within the organization.
3
Real-World Applications of Ethereum
Voting
Agreements
Banking systems
Shipping
Crowdfunding
Domain names
Benefits of Ethereum
Availability: As the Ethereum network is decentralized so there is no downtime. Even if
one node goes down other computing nodes are available.
Privacy: Users don’t need to enter their personal credentials while using the network for
exchanges, thus allowing them to remain anonymous.
Security: Ethereum is designed to be unhackable, as the hackers have to get control of
the majority of the network nodes to exploit the network.
Less ambiguity: The smart contracts that are used as a basis for trade and agreement on
Ethereum ensure stronger contracts that differ from the normal traditional contracts which
require follow-through and interpretation.
Rapid deployment: On Ethereum decentralized networks, enterprises can easily deploy
and manage private blockchain networks instead of coding blockchain implementation
from scratch.
Network size: Ethereum network can work with hundreds of nodes and millions of
users.
Data coordination: Ethereum decentralized architecture better allocates information so
that the network participants don’t have to rely on a central entity to manage the system
and mediate transactions.
Drawbacks of Ethereum
What is Bitcoin?
Bitcoin is a cryptocurrency, which is a form of digital, private money that works
independently without the intermediaries such as bank or government. It is a digital token,
or virtual currency, as well as the network on which such tokens can be stored and
moved. Bitcoin is a digital currency that can be transferred on a peer-to-peer (P2P) network
without the need for any central authority.
It was invented by a person or group of people with the name Satoshi Nakamoto in 2008.
All the transactions are stored in an immutable distributed ledger.
4
Bitcoin is created, stored, transacted, and distributed using a decentralized, distributed
system known as Blockchain.
A public ledger records all the transactions of the Bitcoin and copies are retained on all
the servers around the world.
It is not necessary to buy an entire bitcoin, one can buy only a fraction of it if that is all
necessary.
BTC is the abbreviation for Bitcoin.
Features of Bitcoin:
Distributed: All bitcoin transactions are recorded in a public ledger known as
the blockchain. There are nodes in the network that maintain copies of the ledger and
contribute to the correct propagation of the transactions following the rules of the
protocols making it impossible for the network to suffer downtime.
Decentralized: There is no third party or no CEO who controls the bitcoin network. The
network consists of willing participants who agree to the rules of a protocol and changes
to the protocol are done by the consensus of its users. This makes bitcoin a quasi-political
system.
Transparent: The addition of new transactions to the blockchain ledger and the state of
the bitcoin network is arrived upon by consensus in a transparent manner according to
the rules of the protocol.
Peer-to-peer: In Bitcoin transactions, the payments go straight from one party to another
party so there is no need for any third party to act as an intermediary.
Public: All bitcoin transactions are available publicly for everyone to see. All the
transactions are recorded, which eliminates the possibility of fraudulent transactions.
Permissionless: Bitcoin is completely open access and ready to use for everyone, there
are no complicated rules of entry. Any transaction that follows the set algorithm will be
processed with certainty.
Pseudo-anonymous: Bitcoin transactions are tied to addresses that take the form of
randomly generated alphanumeric strings.
Bitcoin transactions are digitally signed for security. Everyone on the network gets to know
about a transaction. Anyone can create a bitcoin wallet by downloading the bitcoin program.
Each bitcoin wallet has two things: public key and private key.
A bitcoin transaction contains three pieces of information:
Private key: The first part contains the bitcoin wallet address of the sender i.e. the
private key. It is like a digital signature via which anyone can send bitcoins.
Amount of bitcoin to be transferred: The second part contains the amount that has
been sent.
5
Public key: The third part contains the bitcoin wallet address of the recipient i.e. the
public key. It is like an address or an account number via which any user or account can
receive bitcoins.
The public key can be shared with anyone but the private key must be held by the owner. If
the private key gets hacked or stolen then bitcoin gets lost.
In the Bitcoin network, there are nodes that use the computing power of their CPU to process
the transactions. The following are the steps followed while mining a bitcoin:
The user initiates the bitcoin transaction by listing the details like the number of
bitcoins to be sent, and the public address, and affixing the private key to generate a
digital signature. The encrypted information to the miners present on the network.
The miners will verify the transaction to check whether there is sufficient balance to
carry out the transaction.
The faster the CPU of a miner, the greater the chances for the miner to get rewarded
for verifying the transaction. The miner’s job is only to provide the CPU, there is no
manual intervention from the miner. The bitcoin program will run automatically on the
system.
Once the transaction is verified, the number of transactions is broadcasted to the
network of miners who can copy or download the block.
These blocks through timestamps are stored in sequential order to form a
blockchain.
Each miner in the network must have an updated copy of the blockchain ledger in
order to earn bitcoins.
Benefits of Bitcoin
6
Drawbacks of Bitcoin
7
Bitcoin vs Ethereum: Below are some of the differences between Bitcoin and Ethereum:
Sl.No Basis Bitcoin Ethereum
Bitcoin (abbreviation: BTC; sign: ₿) is a decentralized Ethereum is a decentralized global software platform
1 Definition digital currency that can be transferred on the peer-to-peer powered by blockchain technology. It is most commonly
bitcoin network. known for its native cryptocurrency, ether (ETH).
The word bitcoin was defined in a white paper published Ethereum was conceived in 2013 by programmer Vitalik
2 History
on 31 October 2008. The currency began use in 2009. Buterin, and then went live on 30 July 2015.
The purpose of Ethereum was to utilize blockchain
The purpose of bitcoin was to replace national currencies
3 Purpose technology for maintaining a decentralized payment
during the financial crisis of 2008.
network and storing computer code.
Although bitcoin do have smart contracts, they are not as Ethereum allows us to create smart contracts. Smart
flexible or complete as Ethereum smart contracts. Smart contracts are computer codes that is stored on a
4 Smart Contracts
contracts in Bitcoin does not have all the functionality that blockchain and executed when the predetermined terms
a programming language would give them. and conditions are met.
Smart Contract
Smart contracts on Bitcoin are written in programming Smart contracts on Ethereum are written in
5 Programming
languages like Script, Clarity. programming languages like Solidity, Vyper, etc.
Language
Ethereum transactions may contain some executable
6 Transactions Generally, bitcoin transactions are only for keeping notes.
code.
7 Hash Algorithm Bitcoin runs on the SHA-256 hash algorithm. Ethereum runs on the Keccak-256 hash algorithm.
Consensus The Proof-of-Work (PoW) is the consensus mechanism The Proof-of-Stake is the consensus mechanism used by
8
Mechanism used by the Bitcoin network. Ethereum.
9 Block Time The block time of bitcoin is 10 minutes. The block time of Ethereum is 14 to 15 seconds.
10 Block Limit The bitcoin blockchain has a block limit of 1 MB. The Ethereum blockchain does not have a block limit.
Bitcoin is the most popular digital currency in the market Ether, native currency of Ethereum is the second-largest
11 Popularity
to date. cryptocurrency after bitcoin to date.
12 Energy Consumption Energy consumption is very high. Energy consumption is very low as compared to bitcoin
13 Structure Structure of bitcoin is simple and robust. Structure of Ethereum is complex and feature rich
Miner got nearly 6.25 BTC on successfully adding new Miner got nearly 5 BTC along with same additional
14 Rewards
block in network. rewards on successfully adding new block in network.
15 Assets Assets of Bitcoin is BTC. Assets of Ethereum is Ether.
8
1.3 ETHEREUM CLIENTS
2. Light Client: Ethereum clients do not always need to necessary keep all of the data, so
often, when data storage and performance are concerns, developers utilize the “light
clients”. Light clients provide a portion of full client capability. Because light clients do
not keep the entire Ethereum blockchain, as a result, they can provide quick delivery and
free up data storage space.
The functionality of a light client is adapted to the purposes of the Ethereum client.
Light clients, for example, are widely used within wallets to maintain private keys
and Ethereum addresses.
They also manage smart contract interactions and transaction broadcasts.
Light clients are also useful for web3 instances within JavaScript objects, Dapp
browsers, and obtaining the exchange rate data.
3. Remote Client: A remote client is much like a light client. The primary distinction is
that a remote client does not keep its own copy of the blockchain or validate transactions
or block headers. Remote clients, on the other hand, rely entirely on a full or lite client
to have access to the Ethereum blockchain network. These clients are mostly used as
wallets for transmitting and receiving transactions.
9
Benefits of Ethereum client implementations:
There are several benefits to having so many Ethereum client implementations, including the
following as follows.
1. It strengthens the network’s bug resistance.
2. It keeps development resources from being centralized.
3. In general, team contests aid in the discovery of the best solutions to common and difficult
problems.
4. In mining, prototyping, DApp development, and other areas, each customer may have a
distinctive emphasis, strength, and weakness. DApp developers and private Ethereum
blockchain operators may pick and choose which ones best suit their purposes.
An Ethereum node is a computer that is running the software client. The blockchain network is
made up of nodes, which are the only method to access it. Nodes communicate with one another
in order to validate transactions and record data about the status of the blockchain. On the
Ethereum network, these computers or servers are responsible for storing, validating, and
trading data.
Each node keeps its own copy of the blockchain and strives to verify that it matches the
copies of all the other nodes.
Every node on the network must process any action that requires a new block to be added to
the blockchain.
This network of continually communicating nodes allows us to avoid relying on a single
source of truth and all of the challenges it entails.
A new block is added based on whether or not the majority of nodes accept it.
1. Full Node: The responsibility of a full node is to verify and validate each and every
transaction that takes place inside the network and maintain the state of the blockchain. When a
smart contract transaction occurs, full nodes also execute all of the instructions in the smart
contract. It determines whether or not the smart contract execution is producing the expected
results. These nodes maintain a full copy of the blockchain data.
It keeps receiving copies of the entire blockchain including its transactions which are stored
locally and keeps the latest state of transaction with itself.
When a smart contract transaction occurs, full nodes also execute all of the instructions in
the smart contract.
It determines whether or not the smart contract execution is producing the expected results.
Consider an example where person A performs a transaction to person B, this transaction is
added to the blockchain, then the full nodes verify whether the transaction complies with all
the Ethereum specifications, and maintain the latest state of the blockchain by storing or
removing the specification if it does not comply.
An example of a discarder transaction is when a person transfers X ETH to another person
but their account contains less ETH.
10
2. Archive Nodes: Archive nodes are complete nodes that have the “archive mode” option
enabled. While a Full Node only stores the latest state of the transaction, the Archive nodes hold
all of the blockchain’s history data dating back to the genesis block.
The Archive node is used when blocks prior to the latest 128 blocks are required.
For example, using functions like eth_getBalance of a historic address would require an
archive node, as will interacting with smart contracts launched far earlier in the blockchain.
Because of its special feature, Archive Nodes require more than 6 Terabytes of space,
contrary to Full node which only requires a little over 500 Gigabytes of diskspace.
So, it can be inferred, that archive nodes are not useful for average people, they are effective
in the application of block exploring, wallet vending, and chain analytics.
3. Light Nodes: A light node, unlike a full node, does not hold the complete current blockchain
state and stores only the block header. It is suitable for low memory and computational devices
since maintaining a light node involve the least investment in hardware, running costs, and
technical skill.
Light nodes rely on full nodes to function.
These nodes do not need to run continuously or read and publish a large amount of data on
the blockchain.
It provides an easy way to create a wallet, especially for beginners.
For example, Solid-State Drives cannot afford to store the gigabytes of data that other nodes
take.
But there are some limitations of light nodes which cannot be denied, there is no guarantee that
the light wallet provider will be online when it is needed.
11
1.4 ACCOUNT MANAGEMENT
Ethereum Accounts?
Ethereum is a digital, blockchain-based open source digital cryptocurrency platform which also
has the functionality of smart contracts. The cryptocurrency of Ethereum is called Ether (ETH).
The Ethereum network is like a blockchain network but it also enables apps and contracts instead
of only making transactions.
A smart contract is a program that runs on the Ethereum blockchain, they are used to define an
agreement or a contract and make sure that it is being followed, an amazing use case of smart
contracts would be in ensuring quality management of factory-made products by providing
transparency and traceability regarding product origins and other information about things eaten
on a daily basis from a global supply chain.
12
Different Fields in Ethereum Accounts
1. Nonce: The nonce in an Ethereum account indicated the number of transactions that have
been sent from that account. This ensures that each transaction is made only once by taking
count every time it takes place.
2. Ether Balance: The balance of an Ethereum account denotes the amount of ether present in
an ether repository of the current ether account.
3. Contract Code: This is non-mandatory to fill, in case it is present since not all accounts have
a contract code. But note, that they cannot be altered once executed.
4. Storage: This field remains not filled unless mentioned.
5. Code Hash: The value of the code hash for Contract Accounts will be a hash that refers to
the code present in that Ethereum account and since no code is associated with externally
owned Ethereum accounts, therefore, code hash will be an empty string.
Externally owned account (EOA): Externally owned accounts are controlled by private
keys. Each EOA has a public-private key pair. The users can send messages by creating and
signing transactions.
This is the most basic type of Ethereum account, it functions similarly to a bitcoin account.
A private key controls the Ethereum address for EOAs. A person can open as many EOAs
as they require. It is created whenever a wallet is created, and it is made with a private key
that is required to access EOAs, check balances, send and receive transactions, and establish
smart contracts.
Externally Owned Accounts and Key Pairs
An Ethereum account is a private-public key pair that may be linked to a blockchain address.
1. It is a “owned” or “externally owned” account if the private key is known and controlled
by someone.
2. Otherwise, we’re talking about smart-contract accounts if the private key is unknown and
just an address exists.
Contract accounts do not have a private key connected with them, although externally owned
accounts have. Control and access to one’s assets and contracts are granted through the EOA
private key.
Control and access to one’s assets and contracts are granted through the EOA private
key. The user keeps the private key safe.
While, as the name implies, the account’s public key is open. This key serves as the
account’s identity. A one-way cryptographic function is used to produce the public key
from the private key.
For example, if you create an account on Ethereum, you will retain the private key to
yourself while sharing the public key. Transactions between accounts are completed
using public keys.
Advantages of EOA:
Transactions from an external account to a contract account can trigger code that can
execute many different actions, such as transferring tokens or even creating a new
contract.
Externally Owned Accounts cannot list incoming transactions.
13
Contract Account: Contract accounts are controlled by contract codes. These codes are
stored with the account. Each contract account has an ether balance associated with it. The
contract code of these accounts gets activated every time a transaction from an EOA or a
message from another contract is received by it. When the contract code activates, it allows
to read/write the message to the local storage, send messages and create contracts.
Contract-based accounts can perform all of the functions of an externally owned account, but
unlike EOAs, they are formed when a contract code is deployed, are governed by contract
codes, and are accessed using a unique address. When one party accepts a contract, a unique
account is formed which contains all of the charges associated with that contract. Each
contract is granted a distinct serial number, which is referred to as a contract account.
Types of Contract Accounts
Below are the three types of contract accounts:
i. Simple Account: The account is created and owned by a single account holder.
ii. Multisig (multisignature) Account: A Multisig Wallet contains several owner
Accounts, one of which is also the creator Account.
iii. Simplest Account: A Multisig Wallet contains several owner Accounts, one of which
is also the creator Account.
14
1.5 ETHER
What is Ether(ETH)?
Ether (ETH) is the native cryptocurrency of the Ethereum network. It serves as the fuel that
powers the execution of smart contracts, enables transactions, and facilitates interactions within
the Ethereum ecosystem.
Ether is the transactional token that facilitates operations on the Ethereum network. All of the
programs and services linked with the Ethereum network require computing power, equipment,
internet connections, and maintenance. Ether is the payment users give to network participants
for executing their requested operations on the network.
It is more accurate to refer to ether as the "gas" that powers the network. Gas is the term the
community uses to refer to the exchange of ether for the work done to verify transactions and
secure the blockchain.
A distributed, worldwide virtual computer hosts the platform and the blockchain. It uses nodes
(the remote hosts), a consensus layer, an execution layer, and volunteers who provide the
equipment necessary for hosting the virtual machine.
The operational costs of maintaining a host and participating in the network and blockchain are
minimal, but the volunteer validators must stake valuable ether of their own to host nodes.
Validators receive a chance to validate transactions and earn a reward for their work, issued in
ether (ETH).
In order to support the Ethereum network, developers need the cryptocurrency, Ether,
to create and run applications. Ether is used to pay for transaction fees and
computational services.
Users can send Ether to other users, and developers can write smart contracts that
receive, hold, and send Ether.
Ether comes into existence by the validation of transactions on the Ethereum
platform, through a process called mining. Those performing this validation are
referred to as “miners”.
When miners successfully verify a group of transactions, they are awarded
Ether. Miners follow a set of cryptographic rules which keep the network stable,
safe and secure.
Ether transactions are recorded and verified on a digital public ledger called
blockchain.
15
Ethereum Wallets
What is Ethereum?
Ethereum is a decentralized blockchain platform that enables the development and execution of
smart contracts and decentralized applications (DApps). It provides a foundation for building
various blockchain-based solutions and allows for the creation of programmable digital assets.
Ether Uses
Transaction Fees and Gas: Ether is used to pay transaction fees on the Ethereum network.
Users must include a fee, known as “gas,” to incentivize miners or validators to process and
validate transactions.
Smart Contract Execution: Ether is required to execute smart contracts on the Ethereum
network. It serves as the currency for deploying and interacting with these self-executing
agreements.
Decentralized Finance (DeFi): Ether plays a significant role in DeFi applications. It can be
used as collateral for loans, liquidity provision, yield farming, and governance within DeFi
protocols.
Token Creation and ICOs: Ether has been instrumental in the creation of tokens on the
Ethereum platform. Many projects conduct Initial Coin Offerings (ICOs), raising funds by
selling their tokens in exchange for Ether.
Interoperability and Integration: Ether can be tokenized as Wrapped Ether (WETH) and
used on other blockchain platforms, enabling interoperability and seamless integration
between Ethereum and other ecosystems.
16
How do you obtain Ether?
There are multiple ways for an individual to obtain Ether.
It can be purchased on an exchange using a fiat currency under the symbol ETH.
It can be exchanged for Bitcoin on exchanges that offer a BTC-ETH pair.
It can be transferred to you from another person or entity.
It can be earned as a miner, through joining a mining pool or by purchasing a cloud mining
contract
The ETH fees that result from transacting on the Ethereum blockchain are referred to
as gas. In this sense, ETH is the fuel that powers the Ethereum network. This provides a
continued demand for ETH, as both service providers and end users on the Ethereum
network must continually purchase and spend ETH in order to interact with one another
via the network’s smart contract protocols.
Among Ethereum users, gas costs are denoted in gwei, a denomination of ether equal to
0.000000001 ETH. The exact size of this cost per on-chain operation depends on the
computational effort required to complete that action, and can therefore be influenced by
how congested the network traffic is at the time the action is initiated.
For the sake of transparency, approximated gas fees are typically communicated to a user
before they are prompted to initiate a transaction, and many services built on Ethereum
allow users to pay a higher gas fee than is recommended in order to expedite their
transaction or increase the likelihood that it will be successfully executed by the network.
Alternatively, since gas fees can fluctuate in accordance with network usage volatility, Ethereum
users who want to avoid paying excessive ether transaction fees can set a gas limit for their
transaction, which means that their proposed transaction will not be executed if the involved cost
surpasses a certain value.
ETH gas fees also act as a spam mitigation tool in the sense that nefarious actors who might
otherwise attempt to disrupt the system via a cascade of low-quality transactions are financially
deterred by the prospect of paying ETH gas fees.
17
Ether vs Bitcoin : How Is Ether Different from Bitcoin?
Purpose
Most importantly, the overall aims of the networks are different. Bitcoin was created as a
secure peer-to-peer decentralized payment system, an alternative to traditional currencies.
The Ethereum platform was created to facilitate contracts and applications, and ether is
the medium through which these transactions are made possible. Ether was never intended
to be an alternative currency or to replace other mediums of exchange, but it has become
one. Its original purpose was to facilitate and monetize the operations of the Ethereum
platform.
Unlike Bitcoin, the total number of ether tokens does not have an absolute cap—it changes
and grows constantly according to demand. As a result, the Ethereum blockchain is
significantly larger than the Bitcoin blockchain, and it is expected to continue to outpace
Bitcoin in the future.
18
Network Effects and Community: Ethereum benefits from a strong and active community
of developers, enthusiasts, and stakeholders. The collective efforts and collaborations within
the Ethereum community contribute to the network effects, driving adoption, innovation, and
the overall value of Ether.
Decentralization and Security: As a cryptocurrency native to a decentralized blockchain
platform, Ether offers security and immutability. It operates on a distributed network of
nodes, reducing the risk of censorship, single points of failure, and unauthorized alterations,
providing users with increased trust and confidence.
Potential for Growth and Adoption: Ether’s early adoption and continued development
make it well-positioned for potential future growth. As more industries embrace blockchain
technology and decentralized applications, Ether’s value may increase as it becomes an
integral part of innovative solutions across various sectors.
Overview:
Vitalik Buterin, a programmer, proposed Ethereum in 2013. The network went live in 2015,
with an initial supply of 72 million coins, after being crowdfunded in 2014.
The Ethereum Virtual Machine (EVM) can run decentralized programs and execute scripts.
Ethereum is used for decentralized banking, the production and distribution of non-fungible
tokens (NFTs), and many ICOs.
After Bitcoin, Ethereum is quoted as the second most prevalent crypto-currency. Unlike
Bitcoin, Ethereum is proposed to be much more than simply a means of exchange or a store
of value.
Ethereum, on the other hand, refers to itself as a decentralized computer network based on
blockchain technologies. Ethereum is built on top of a blockchain network. A blockchain is
a transparent, distributed public ledger that verifies and records all transactions. Everyone
on the Ethereum network has an exact copy of this ledger, which allows them to view all
previous transactions.
The Ethereum network allows users to build and run apps, smart contracts, and other
transactions. These features are not available in Bitcoin.
It is only used as a medium of exchange and a store of cash. There is no boundary on how
much Ether tokens can be produced while Bitcoin can only deliver 21 million coins.
All, regardless of context or location, have access to digital money and data-friendly
resources thanks to Ethereum. It’s the technology that powers the ether (ETH) and thousands
of other apps available today.
The Ethereum Virtual Machine (EVM) is run by Ethereum clients, which may be built in any
popular programming language.
19
Types of Ethereum Network
There are three types of Ethereum networks — the public mainnet, the private mainnet, and the
testnet. According to Ethereum Foundation’s research center, a new hybrid network called Whisper
Network is under development.
i. Public mainnet : The public Ethereum network has two variations: Homestead and
Metropolis. The first one was launched in March 2015 via a hard fork which resulted in a
different set of network parameters that enabled smart contract transactions.
In 2016, the Foundation planned another hard fork called Metropolis to improve efficiency and
flexibility when dealing with transactions and smart contracts on the blockchain.
With the new hard fork come both the public mainnet (Metropolis) and the testnet (Ropsten).
ii. Private mainnet: In a private Ethereum network, membership is controlled and limited to
certain users who are carefully selected by administrators. It is used to protect against malicious
attacks and limit access only to trusted parties — which makes it an ideal solution for
companies looking to develop applications based on cryptocurrency.
Private networks can be built in-house or hosted by a third-party service provider such as
Microsoft Azure or Amazon Web Services.
iii. Testnet: The testnet is used by those who want to experiment with their code before launching
it on the mainnet. Users who want to try out the testnet can create a new node and join the
network — or they can connect their private networks to the public testnet.
A functional public testnet is a necessary component of an Ethereum-based app as most
developers use it to test their apps, smart contracts, and other solutions based on blockchain
technology.
iv. Whisper Network (sharding): The Whisper Network was originally developed as a platform
for private messaging between users in an Ethereum-based app or decentralized application
(dapp).
To understand how the Whisper Network works, it is necessary to have a basic understanding
of “sharding”. The network is made up of shards that are linked together by the use of complex
cryptography. Each of these shards can contain multiple nodes and are collectively updated by
their leader nodes at specific intervals. The Whisper Network uses a combination of high-speed
encryption developed by the Ethereum Foundation, sharding technology, and distributed
storage solutions.
There are two types of nodes in an Ethereum network. They are as follows.
1. Mining Node: These nodes are responsible for writing all the transactions that have occurred
in the Ethereum network in the block.
20
2. Ethereum Virtual Machine Node: These are the nodes in the Ethereum network in which
Smart Contracts (it is a type of contract between supporter and developer in which there are
a set of rules based on which both the parties agree to interact with each other. The agreement
will be automatically executed when the pre-defined rules are met.) are implemented. By
default, this node utilizes a 30303 port number for the purpose of communication among
themselves.
3. Seed Node
4. Peer Node
Component-2: Ether
Just like we have money to do the exchange of goods in real world, we need Ethers to
exchange data or perform any kind of operation in Ethereum Blockchain. Ether is a type of
cryptocurrency used in the Ethereum network just like a bitcoin is used in a blockchain
network. It is a peer-to-peer currency, similar to Bitcoin. It tracks and promotes each
transaction in the network.
It is the second-largest cryptocurrency in the world. The first one is Bitcoin. Other
cryptocurrencies can be used to get ether tokens, but vice versa is not true.
It means that ether tokens can’t be interchanged by other cryptocurrencies to render
computing power for Ethereum transactions. Ether is paid as a commission for any execution
that affects the state of Ethereum.
It is used in the Ethereum algorithm as an incentive for miners who connect blocks to the
blockchain using a proof-of-work method.
It is the only currency that can be used to pay transaction costs, which go to miners as well.
The block reward, as well as transaction fees, provide miners with an opportunity to keep the
blockchain rising.
Aside from paying for transactions, ether is often used to purchase gas, which is used to pay
for the computation of any transaction on the Ethereum network.
Component-3: Gas
Gas is an internal currency of the Ethereum network. We need gas to run applications on the
Ethereum network, much as we need gas to run a vehicle.
To complete every transaction on the Ethereum network, a consumer must first make a
payment—send out ethers—and the intermediate monetary value is known as gas.
Gas is a unit of measurement on the Ethereum network for the computing power used to
execute a smart contract or a transaction.
The price of gas is very low compared to Ether. The execution and resource utilization costs
are predetermined in Ethereum in terms of Gas units, called gwei.
2. Contract account: As the name itself suggests, these accounts store the details of Smart
Contracts.
21
Component-5:Nonce
For externally owned accounts, nonce means the number of transactions via this account. For a
contract account, nonce means the number of contracts generated via this account.
22
4. Taking random slices of the dataset and hashing them together is what mining is all about.
Verification may be done with little memory by utilizing the cache to renew just the parts of
the dataset that you require, requiring just the cache to be stored.
1.7 MINING
What is Crypto Mining?
Crypto mining simply refers to the process of generating new digital coins or adding blocks in
the chain. It can be achieved by solving a complex mathematical problem with the help of a
sophisticated crypto-mining hardware device such as ASICs (Application-specific integrated
circuits).
Bitcoin Mining is the process of verifying bitcoin transactions and storing them in a
blockchain(ledger). It is a computer process that creates new bitcoin in addition to tracking
Bitcoin transactions. Bitcoin mining is a computation-intensive process that uses complicated
computer code to generate a secure cryptographic system. The bitcoin miner is the person who
solves mathematical puzzles (also called proof of work) to validate the transaction.
Why do Bitcoin Needs to Be Mined?
Mining solves these problems by making the below illicit activities extremely expensive and
resource-intensive.
Bitcoin is a digital currency where there are chances of copying, counterfeiting, or
double-spending the same coin more than once.
It is more beneficial and cost-effective to join the network as a miner than to try to
undermine it.
23
Types of Bitcoin Mining
A bitcoin can be mined mainly in 3 ways.
GPU Mining: In this process, coins are mined with the help of a graphics card.
CPU mining: In this process, coins are mined with the help of a central processing unit.
ASIC mining: ASICs (application-specific integrated circuits) is one of the most widely
used bitcoin mining methods that work on a specific algorithm.
24
Role of bitcoin miners:
The role of the miners is to process and confirm transactions to chain together the blocks of
transactions.
Typically, these miners use very powerful computers that are specifically designed to mine
bitcoin transactions, and the way they do that is by actually solving math problems and
resolving cryptography issues, because every one of these transactions need to be
cryptographically encoded and secured.
These mathematical problems are what actually ensures that the data is secure and nobody
is tampering with that data.
For the miners to earn rewards from verifying the bitcoin Transactions, two things must be
ensured:
The miners must verify the one-megabyte size of the transaction.
For the addition of a new block of transaction in the blockchain, miners must have the
ability to solve complex computational maths problems called proof for work by finding
a 64-bit hexadecimal hash value.
Example:
Let’s understand this with the help of an example-
25
Once maximum nodes agree with the solution, the transaction block is verified and is
then added to the blockchain.
At the same time, the miner who solved the puzzle gets a reward of 6.25 bitcoins.
Now, after the addition of the transaction block, the 10 BTC associated with the
transaction data is transferred to Bob from Alice.
Components of bitcoin:
There are four components
of bitcoin:
i. Software
ii. Cryptography
iii. Hardware
iv. Gaming theory
Software: Bitcoin is basically a software that defines how a bitcoin gets transferred. It identifies
what are the rules of a valid bitcoin. That software at its core uses cryptography and bitcoin is a
cryptocurrency.
Cryptography: As a cryptocurrency it uses cryptography to regulate the transfer of bitcoin
between parties as well as creation of new units of bitcoin. So, if it wasn’t for cryptography,
bitcoin would simply not be possible. All this needs to run on hardware.
Hardware: This hardware is composed of thousands of miners around the world running their
computers.
Gaming Theory: The final component that ties it all together is gaming theory. Because bitcoin
in essence is truly a game that is run by these miners around the world.
In past, users of the system used to mine bitcoins using their home computers but as the
technology has improved, this is no longer the case. The general time a bitcoin network takes to
verify a new transaction is 10min. Within that time, there are more than one million miners
competing with each other to find the hash value. When there is more computing power working
together to mine for bitcoins, the difficulty level of mining increases. Therefore, in order to mine
bitcoins, the user must possess-
Specialized mining hardware is called “application-specific integrated circuits,” or ASICs.
A Bitcoin mining software to join the Blockchain network.
Powerful GPU (graphics processing unit).
26
2. Buying the Mining Hardware: After ensuring the feasibility of mining bitcoins, the user
must purchase mining hardware like ASICs.
3. Mining Software: For proper access to bitcoin, mining software provides a pathway to
join the Blockchain network. There are lots of free mining software available online.
4. Installing Bitcoin Wallet: After the user receives bitcoins as a reward for mining, the
bitcoins are to be kept in the bitcoin wallet.
5. Joining a Mining Pool: This increases the possibility of mining bitcoins efficiently.
27
1.8 HISTORY OF ETHEREUM
2013: Ethereum was first described in Vitalik Buterin’s white paper in 2013 with the goal of
developing decentralized applications.
2014: In 2014, EVM was specified in a paper by Gavin Wood, and the formal development
of the software also began.
2015: In 2015, Ethereum created its genesis block marking the official launch of the
platform.
2018: In 2018, Ethereum took second place in Bitcoin in terms of market capitalization.
2021: In 2021, a major network upgrade named London included Ethereum improvement
proposal 1559 and introduced a mechanism for reducing transaction fee volatility.
2022: In 2022, Ethereum has shifted from PoW(Proof-of-Work ) to PoS( Proof-of-Stake)
consensus mechanism, which is also known as Ethereum Merge. It has reduced Ethereum’s
energy consumption by ~ 99.95%.
1.9 COMMUNITY
28
promoting cryptos, organizing giveaways, shouting out to active members, and sharing
new information.
Before joining crypto communities, the person should read the guidelines properly. Most
communities provide clear and defined rules- not strict ones, so all members can enjoy the essence
of community without any conflict.
29
Reddit: You can find almost every topic relating to crypto on this platform, from beginners to
advanced, and it’s also a place where meme coins are born. You can follow up on specific
subreddits or tags to keep up with the latest news and developments.
Nevertheless, until today the EF is the most influential organization within the Ethereum
ecosystem and its actions are closely followed across the crypto universe.
The EF’s mission is to secure Ethereum’s long-term success. It allocates resources to critical
projects, funds research, development, and education out of its massive treasury, is a valued voice
within the Ethereum community, and advocates for Ethereum to the world outside of blockchains.
Its goal is to empower developers to create next-generation decentralized protocols and lay the
foundation for a more free and trustless internet.
30
Who controls the Ethereum foundation?
The Ethereum Foundation is run by an executive board consisting of three people. Aya Miyaguchi
serves as the foundation’s executive director, with Vitalik Buterin and Patrick Storchenegger
completing the board. The foundation works closely with developer teams and the Ethereum
community.
The EF has no control over Ethereum but can allocate the foundation’s resources according to its
vision for Ethereum. Since a solo mission by the EF is likely to fail, the EF has to stay in close
contact with the Ethereum community to make sure their interests are aligned.
The Ethereum Foundation was created in the summer of 2014 by Vitalik Buterin, Gavin Wood,
and other members of the Ethereum founding team. The non-profit organization was created to
govern the development efforts of Ethereum and to manage the organization’s treasury.
In February of 2014, the Ethereum team had already founded Ethereum Switzerland Ltd., a
registered company based in Zug, Switzerland, to manage the development of Ethereum under a
legal structure. To further fund the project, the team decided to conduct an online public crowd
sale — generally referred to as an ICO, which stands for Initial Coin Offering — from July to
August 2014. In this sale, investors could buy 2,000 Ether for 1 Bitcoin.
Additionally, the EF owns $300 million in non-crypto assets, which are mainly held in fiat
currencies. This ensures that the EF has sufficient resources and liquidity in case of a multi-year
market downturn without having to sell its ETH at unfavorable prices. The cash position has been
built by selling part of the foundation’s ETH holdings over recent years. Vitalik has proven to have
an exceptional ability to time the market, as he managed to convince the EF board twice to sell
large ETH positions at the market top, right before prices collapsed again.
How does the Ethereum foundation make money?
Ether, Ethereum’s native coin, was pre-mined at the launch of the Ethereum network on July 30,
2015. In total, 72 million Ether were created that day. Sixty million Ether went to the investors
that participated in the public pre-sale the year before, another 6 million were given to the creators
and developers of Ethereum, and the remaining 6 million Ether was deposited with the Ethereum
Foundation.
Since that day, the Ethereum Foundation has financed all its activities with this initial Ether
donation. Technically, the Ethereum Foundation does not currently make any money or receive
any cash flows from the Ethereum network. Nevertheless, in U.S.-dollar terms, the foundation is
much better off than at the beginning, thanks to the strong appreciation of Ether.
31
While the amount of Ether in their wallet is steadily decreasing, their treasury measured in U.S.
dollars has been steadily increasing. As long as the Ether price is appreciating, the foundation will
be able to sustain itself for many years to come. And with Ethereum’s switch from Proof-of-Work
to Proof-of-Stake, the foundation will be able to stake parts of its Ether holdings on the network
to generate a steady return in ETH, which might even be enough to pay for all their expenses in
the future.
32
The role of this foundation is to dedicate efforts to promote the adoption, development
and research of solutions on Ethereum. But it also dedicates efforts to promoting
technologies related to this ecosystem.
Ethereum Foundation Philosophy
The main philosophical ideal that drives the Ethereum Foundation is to maximize value
and all that Ethereum represents to the world. An ideal that they have maintained since its
inception and that they have been cultivating together with the community that contributes
and supports the Ethereum project.
It has an important role in making decisions about the evolution of the cryptocurrency. But
very especially, in those related to research, development and community cultivation that
favors the ecosystem.
The Ethereum Foundation has created and maintained a philosophy accepted by all its
parts, in order to encourage decentralization, free expression of ideas, coordination and
leadership within the project, organizing the project following the development model
"Bazar ”(Like that of free software projects like LibreOffice or the Linux kernel), instead
of“ Cathedral ”(like most proprietary software or free software projects like GCC).
With the "Bazaar" development model, what is sought is that people can see, review and improve
the project in a completely autonomous way, present their improvements, discuss them and include
them if they are really profitable or solve a problem for everyone within the company. community.
Something that in the "Cathedral" model would be quite difficult to achieve, due to the existence
of well-defined tasks and roles for each of the parts of the project that limit their access or work
within it.
In fact, the Ethereum Foundation represents its philosophy in four parts which are:
1. Instead of capturing opportunities, we distribute opportunities to others.
2. Rather than being defensive when others create value, we are delighted.
3. We don't want to import more; we try to import less.
4. Ultimately, any philosophy is only as good as the choices it inspires.
History:
In 1994, Nick Szabo, a legal scholar, and a cryptographer recognized the application of a
decentralized ledger for smart contracts. He theorized that these contracts could be written in
code which can be stored and replicated on the system and supervised by the network of
computers that constitute the blockchain. These smart contracts could also help in transferring
digital assets between the parties under certain conditions.
34
3. Speed: Smart contracts use software code to automate tasks, thereby reducing the time it
takes to maneuver through all the human interaction-related processes. Because everything
is coded, the time taken to do all the work is the time taken for the code in the smart contract
to execute.
4. Backup: Every node in the blockchain maintains the shared ledger, providing probably the
best backup facility.
5. Security: Cryptography can make sure that the assets are safe and sound. Even if someone
breaks the encryption, the hacker will have to modify all the blocks that come after the block
which has been modified. Please note that this is a highly difficult and computation-intensive
task and is practically impossible for a small or medium-sized organization to do.
6. Savings: Smart contracts save money as they eliminate the presence of intermediaries in the
process. Also, the money spent on the paperwork is minimal to zero.
7. Manages information: Smart contract manages users’ agreement, and stores information
about an application like domain registration, membership records, etc.
8. Multi-signature accounts: Smart contracts support multi-signature accounts to distribute
funds as soon as all the parties involved confirm the agreement.
A smart contract is just a digital contract with the security coding of the blockchain.
It has details and permissions written in code that require an exact sequence of events to take
place to trigger the agreement of the terms mentioned in the smart contract.
It can also include the time constraints that can introduce deadlines in the contract.
Every smart contract has its address in the blockchain. The contract can be interacted with
by using its address presuming the contract has been broadcasted on the network.
The idea behind smart contracts is pretty simple. They are executed on a basis of simple logic,
IF-THEN for example:
IF you send object A, THEN the sum (of money, in cryptocurrency) will be transferred to
you.
IF you transfer a certain amount of digital assets (cryptocurrency, for example, ether,
bitcoin), THEN the A object will be transferred to you.
IF I finish the work, THEN the digital assets mentioned in the contract will be transferred
to me.
Note: The WHEN constraint can be added to include the time factor in the smart contracts. It
can be seen that these smart contracts help set conditions that have to be fulfilled for the terms
of the contract agreement to be executed. There is no limit on how much IF or THEN you can
include in your intelligent contract.
35
Smart Contract Working
Identify Agreement: Multiple parties identify the cooperative opportunity and desired
outcomes and agreements could include business processes, asset swaps, etc.
Set conditions: Smart contracts could be initiated by parties themselves or when certain
conditions are met like financial market indices, events like GPS locations, etc.
Code business logic: A computer program is written that will be executed automatically
when the conditional parameters are met.
Encryption and blockchain technology: Encryption provides secure authentication and
transfer of messages between parties relating to smart contracts.
Execution and processing: In blockchain iteration, whenever consensus is reached between
the parties regarding authentication and verification then the code is executed and the
outcomes are memorialized for compliance and verification.
Network updates: After smart contracts are executed, all the nodes on the network update
their ledger to reflect the new state. Once the record is posted and verified on the blockchain
network, it cannot be modified, it is in append mode only.
1. Real Estate: Reduce money paid to the middleman and distribute between the parties
actually involved. For example, a smart contract to transfer ownership of an apartment once
a certain amount of resources have been transferred to the seller’s account(or wallet).
2. Vehicle ownership: A smart contract can be deployed in a blockchain that keeps track of
vehicle maintenance and ownership. The smart contract can, for example, enforce vehicle
maintenance service every six months; failure of which will lead to suspension of driving
license.
3. Music Industry: The music industry could record the ownership of music in a blockchain.
A smart contract can be embedded in the blockchain and royalties can be credited to the
owner’s account when the song is used for commercial purposes. It can also work in
resolving ownership disputes.
36
4. Government elections: Once the votes are logged in the blockchain, it would be very hard
to decrypt the voter address and modify the vote leading to more confidence against the ill
practices.
5. Management: The blockchain application in management can streamline and automate
many decisions that are taken late or deferred. Every decision is transparent and available to
any party who has the authority(an application on the private blockchain). For example, a
smart contract can be deployed to trigger the supply of raw materials when 10 tonnes of
plastic bags are produced.
6. Healthcare: Automating healthcare payment processes using smart contracts can prevent
fraud. Every treatment is registered on the ledger and in the end, the smart contract can
calculate the sum of all the transactions. The patient can’t be discharged from the hospital
until the bill has been paid and can be coded in the smart contract.
1. Recordkeeping: All contract transactions are stored in chronological order in the blockchain
and can be accessed along with the complete audit trail. However, the parties involved can
be secured cryptographically for full privacy.
2. Autonomy: There are direct dealings between parties. Smart contracts remove the need for
intermediaries and allow for transparent, direct relationships with customers.
3. Reduce fraud: Fraudulent activity detection and reduction. Smart contracts are stored in the
blockchain. Forcefully modifying the blockchain is very difficult as it’s computation-
intensive. Also, a violation of the smart contract can be detected by the nodes in the network
and such a violation attempt is marked invalid and not stored in the blockchain.
4. Fault-tolerance: Since no single person or entity is in control of the digital assets, one-party
domination and situation of one part backing out do not happen as the platform is
decentralized and so even if one node detaches itself from the network, the contract remains
intact.
5. Enhanced trust: Business agreements are automatically executed and enforced. Plus, these
agreements are immutable and therefore unbreakable and undeniable.
6. Cost-efficiency: The application of smart contracts eliminates the need for
intermediaries(brokers, lawyers, notaries, witnesses, etc.) leading to reduced costs. Also
eliminates paperwork leading to paper saving and money-saving.
37
Challenges of Smart Contracts
38
A Simple Smart Contract:
Smart contracts form the basis for all dApps built on the blockchain, and they're typically written
in custom languages such as Solidity (for Ethereum) or Cadence (for Flow).
They tend to be much simpler than traditional programs, but the risks are much higher - a
single smart contract bug can lead to millions of dollars being drained in minutes!
The tools you need to code and deploy your first smart contract, including:
Metamask: A software cryptocurrency wallet used to interact with the Ethereum blockchain,
that will allow you to pay for the gas to publish your transaction.
Solidity: An object-oriented programming language for implementing smart contracts on
Ethereum.
Hardhat: An Ethereum development environment that allows you to compile Solidity
contracts, test contracts on a dev network, and view Solidity stack traces.
Etherscan: An online blockchain explorer that allows you to view transactions, blocks, and
wallet states on a public blockchain.
Alchemy: A web3 developer platform that allows you to connect with the rest of the Ethereum
network via free nodes.
39
How to Create Your First Smart Contract?
Steps to Create and Deploy a Smart Contract
Step 1: Connect to the Ethereum network.
You can connect to the Ethereum mainnet by downloading and installing a MetaMask wallet on
your Chrome browser and enabling it. Once you have completed the setup, proceed to connect it
to the Ethereum mainnet.
40
Step 8: Make smart contract ready to go live.
To prepare a smart contract to go live on a blockchain, procedures such as testing or auditing are
strongly recommended, besides other considerations. Once reassured that the smart contract is
ready to hit the market, the smart contract can be deployed to the Ethereum mainnet.
1.12 DAPPS
What is DApp?
A decentralized application (DApp) is a type of distributed, open source software application that
runs on a peer-to-peer (P2P) blockchain network rather than on a single computer. DApps are
similar to other software applications that are supported on a website or mobile device, but they're
P2P supported. DApps are considered part of Web3, the present evolution of the World Wide Web.
DApps in blockchain are ostensibly similar to any relative web or mobile app. However, this
relates more to their front-end, while under the hood as part of their back-end, are decentralization
and smart contracts.
The decentralized nature of DApps means that, once a developer has released a
DApp's codebase, others can build on top of it. The app is not controlled by a single
authority. DApp development creates a variety of applications, including those for
decentralized finance, web browsing, gaming and social media.
DApps are built on a decentralized network supported by a blockchain distributed ledger.
The use of blockchain means a DApp can process data through distributed networks and
execute transactions. DApps are often built using the Ethereum platform.
Distributed ledger technologies, such as the Ethereum blockchain, have helped popularize
DApps. The major advantages of DApps are that they're always accessible and have no
single point of failure.
dApps work in a manner similar to normal applications except for the few differences that are
discussed below:
The dApp working has the following features:
Decentralized: A dApp operates on Ethereum which is an open public decentralized
platform.
Deterministic: dApps perform the same function irrespective of the environment in which
they are executed.
Turing complete: dApps can perform any action given the required resources.
41
Isolated: dApps are executed in an Ethereum Virtual Machine which is a virtual environment
that ensures that even if there is a bug in the smart contract, it won’t hamper the normal
functioning of the blockchain network.
DApps are stored and executed on a blockchain system, commonly using the Ethereum
network. Apps are validated with cryptographic tokens, which are needed for application
access.
DApps are similar to conventional apps in the front-end code they use to render a webpage.
But their back-end code is different; it runs on a decentralized peer network. This removes
DApps from the control of a single authority.
While centralized servers and databases support a traditional application, a smart
contract stored on a blockchain supports a DApp. Ethereum is the most popular blockchain
for running smart contracts, which enforce rules defined in the code and mediate
transactions. A smart contract consists of the back end only and is often just a small part
of the whole DApp. Therefore, creating a decentralized app on a smart contract system
requires combining several smart contracts and using third-party systems for the front end.
The blockchain that a smart contract runs on is a ledger of data records stored in blocks as
opposed to a central location. The blocks of data remain dispersed across distributed
locations; all the data blocks are linked and ruled by cryptographic validation in the
ecosystem.
Not all DApps work on standard web browsers; some may work only on websites with
customized code to open that specific application.
There are many Blockchain platforms created by various companies. While the most popular
and commonly heard one is Bitcoin, there are many others that are used to create dApps. These
Blockchain platforms are further used as a base to create dApps. So let’s see some of these now:
1. Ethereum: Ethereum is the most popular decentralized, open-source blockchain in the world
currently. It is used as the base for many Blockchain projects, including more than 2500
dApps. In fact, Ethereum is only second to Bitcoin in terms of its market value. Ethereum
also has a native cryptocurrency known as BTH which is their version of Bitcoin. All in all,
this is an excellent option for creating a dApp although it’s a bit expensive.
2. NEO: NEO is also a decentralized, open-source blockchain that aims to create a smart
economy. It is also called the Chinese Ethereum and provides better options for scalability
in dApps as compared to other Blockchain platforms. NEO is currently less popular than
Ethereum with only about 100 dApps built using this technology. It’s also quite expensive
and can even charge higher fees than Ethereum in some cases.
3. TRON: TRON is a comparatively new Blockchain platform as compared to Ethereum or
NEO. However, it’s quite popular and may even become a competitor to Ethereum in the
future. TRON is particularly famous for gaming applications and gambling sites. There are
around 1500 dApps created using this platform which makes it an excellent choice.
42
Popular DApps
dApp Architecture
Below are the components of the dApp architecture:
Ethereum blockchain.
Smart Contracts.
Ethereum Virtual Machine (EVM).
Front-end.
43
Let’s discuss the components in detail: The following Fig.1.8.diagram shows what the actual
architecture of DApp looks like:
1. Ethereum blockchain: Ethereum is a decentralized and open-source blockchain
platform that establishes a peer-to-peer network that securely executes and verifies
application code, called smart contracts. Decentralized applications have their backend
code (smart contracts) running on a decentralized network and not a centralized server.
DApps use the Ethereum blockchain for data storage.
2. Smart Contracts: DApps use smart contracts to define the state changes happening
on the blockchain. A smart contract is a collection of code and data that resides at a
specific address on the Ethereum Blockchain and runs on the Ethereum blockchain. They
are written in high-level languages such as Solidity and Vyper.
44
Communication between Frontend and Smart Contract on Ethereum
To invoke functions the front end needs to communicate with smart contracts. But Ethereum is
a decentralized network. Every node in the Ethereum network keeps a copy of all states on the
Ethereum Virtual machine, including the data and code associated with every smart contract.
It is required to interact with one of these nodes to interact with the data and the code on the
blockchain. This is because any node can broadcast a request for a transaction to be executed on
the EVM. Then the job of a miner is to execute the transaction and propagate the resulting state
change to the network. The transaction can be broadcasted in two ways:
1. Set up the node which runs the Ethereum blockchain software.
2. Use nodes provided by third-party services.
45
Ethereum provider (i.e. nodes) implements a JSON-RPC specification. This ensures that
there’s a uniform set of methods when our frontend applications want to interact with the
blockchain.
One can read the state stored on the blockchain once connected to the blockchain through a
provider.
But if one wants to write to the state before one can submit the transaction to the blockchain
there’s one more thing that needs to be done and the thing is “sign” the transaction using the
private key.
Whenever the front end needs the user to sign a transaction, it calls on Metamask. Here
Metamask plays the role of the signer.
Metamask is a browser plugin that serves as an Ethereum wallet. we know that the Ethereum
blockchain is a network and we need a special browser extension to connect that network.
Metamask will allow us to connect the blockchain with our personal account and interact
with the smart contract.
A user’s private keys are stored by Metamask in the browser, and when a user wants to write
to the state, the user needs to “sign” the transaction using the private key.
Metamask acts both as a provider and a signer because Metamask provides a connection to
the blockchain (as a “provider”) and since it needs it to sign transactions that’s why it is also
a signer.
46
Performance Overhead: There is a lot of performance overhead to achieve the level of
security, transparency, and integrity that Ethereum desires. Even the proof-of-work takes a
lot of time and computational resources.
Centralization: Developing user-friendly, developer-friendly applications on top of
Ethereum may end up developing a centralized service. Centralization may eliminate all the
good features of the blockchain over the traditional model.
DApp scams
The decentralized nature of DApps makes it difficult to track scams and hold perpetrators
accountable. Users must exercise caution to avoid dApp scams such as the following:
Ponzi schemes and fake initial coin offerings, which are the cryptocurrency equivalent of
an initial public offering.
Phishing attacks that trick users into revealing sensitive financial information.
Malware and data theft.
Exit scams where DApps build trust with a community and solicit fundraising before
abandoning a project with users' investments and data.
Pump and dump schemes in which traders create excitement and hype around a DApp to drive
the price to an unsustainable price before selling their shares and crashing the stock.
Smart contract vulnerabilities that can enable attackers to drain funds from a contract.
47
Examples and use cases of DApps
Thousands of DApps have been developed and are in use. The following are three examples:
Chainlink is middleware that provides tamper-proof inputs, outputs and computations for
Oracle networks. Google uses it for its BigQuery platform-as-a-service data warehouse.
TraceDonate is a service that connects charities and donors to beneficiaries with the goal of
building trust that donations reach those in need. Funds are kept in a digital wallet and let the
donor track how the donation is spent.
Minds is a DApp-based social media platform that runs on open source code and encrypts all
personal data that users send.
What is a DAO?
The acronym DAO comes from “Decentralized Autonomous Organization”. A DAO is a type of
organization that is managed and controlled by smart contracts. These contracts are
computational algorithms in the blockchain network that determine the protocols or rules of
collaboration of each party involved. The use of blockchain allows these organizations to be
autonomous, transparent and secure.
48
The concept of a DAO was first proposed by Bit Shares, Steemit, and EOS (Block. one)
founder Dan Larimer in the year 2015, and was further refined in the year 2016 by
Ethereum’s Vitalik Buterin.
In 1997, Professor Werner Dilger, presented his work “Decentralized autonomous
organization of the intelligent home according to the principle of the immune system”. This
is considered the first time that the concept of DAOs was exposed.
In the project, although blockchain technology did not yet exist, Dilger defined the bases of
the DAO as a self-sustaining and autonomous system.
It wasn’t until 2013 that someone talked about this concept. It was Daniel Larimer, founder
of BitShares and Steem, who spoke about Decentralized Autonomous Companies (DAC) in
the Let’s Talk Bitcoin!
In 2015, Vitalik Buterin relaunched the concept with the launch of Ethereum. The Ethereum
network allowed for the first time to create advanced transparent and immutable codes. This
was the first big step in creating real DAOs.
49
Traditional Organization Vs DAO
50
3. A consultant organization: One can make an organization of workers for hire who pool
their assets for office spaces and programming memberships.
4. Adventures and awards: It is possible to make an endeavor store that pools speculation
capital and decisions on dares to back. Reimbursed cash could later be rearranged among
DAO individuals.
So far we are using people to “store” information instead. In order to know how much hiring a
new person would cost? – There is a person answerable in the human resources department.
Similarly, to get movement costs repaid?- There is a separate person responsible for this in the
accounting.
51
shareholders. Shareholders have voting rights just like in regular corporations. They dictate
the general direction and accept or decline initiatives.
The general idea is to bring the benefits of blockchain technology to management.
The blockchain is immutable, precise, and consistent. It is also transparent and open so that
anyone could review companies. Strong consistency makes DAOs reliable business partners.
Such an organization is also harder to put under pressure. It will be difficult to ban it from
operating somewhere. As it is controlled by the organization members and not influenced by
a central government authority to put under pressure.
DAO Membership
There are various models for DAO membership. Membership can decide how casting ballot
functions and other key pieces of the DAO.
1. Token-based membership: Normally completely permissionless, contingent upon the token
utilized. For the most part, these administration tokens can be exchanged for permissionless on
a decentralized trade. Others should be procured by giving liquidity or another ‘evidence of
work’. In any case, just holding the symbolic awards admittance to casting a ballot. Ordinarily
used to administer expansive decentralized conventions as well as tokens themselves.
Example: MakerDAO’s token MKR is generally accessible on decentralized trades. So anybody
can become tied up with having cast a ballot power on the Maker convention’s future.
2. Share-based membership: Offer-based DAOs are more allowed, yet at the same time very
open. Any imminent individuals can present a proposition to join the DAO, typically offering
recognition of some worth as tokens or work. Offers to address direct democratic force and
possession. Individuals can exit whenever with their proportionate portion of the depository.
Regularly utilized for all the nearer sew, human-driven associations like foundations, laborer
assemblages, and venture clubs. Can administer conventions and tokens too.
Example: MolochDAO is centered around financing Ethereum projects. They require a
proposition for enrollment so the gathering can evaluate whether you have the important mastery
and funding to make educated decisions about possible grantees. You can’t simply purchase
admittance to the DAO on the open market.
52
Benefits of DAOs
A DAO can do the following:
Automate the financial processes associated with a distributed organization;
Speed up the fundraising process for a new idea;
Ensure that everyone gets a fair vote in the organization;
Streamline distribution of returns and gains; and
Improve visibility into rules for allocating investments and decisions.
Downsides/Risk of DAOs
However, a DAO carries these downsides and risks:
Automated smart contracts can be difficult to change when a problem is discovered.
Hackers can discover loopholes to legally misappropriate funds against the interests of
shareholders.
Participants can pay high transaction fees of up to $100 per transaction in early DAOs.
Humans are still required to execute physical and legal processes, which can thwart the intent
of the DAO.
Governments are still sorting out the legal status of DAOs, which presents tax and legal risks
for investors.
Advantages of DAO
1. Decentralization: DAO emphasizes being driven by a collective rather than an individual.
With DAO, participants have a much stronger say in the organization’s direction.
2. Community Driven: DAOs make it easy for communities worldwide to connect and build
a prospering vision together. DAO is accessible to Individuals who may have had the
opportunity in the past to connect and work together.
3. Principle-agent dilemma: One of the main advantages of DAO is that it provides a solution
for the principle-agent dilemma. This dilemma is a conflict in priorities between a person
(principle) and the entities making decisions on their behalf (agent). One of the common
examples of this is problems between Stakeholders and CEOs. DAO solves this problem
through community governance. Here, principles don’t have to trust agents who work on
their behalf instead they work as a part of a group whose incentives are aligned.
Disadvantages of DAO
This section lists some of the disadvantages of DAO:
1. Security: DAO can be launched with just a few lines of code and given the immense tech
stack a well-run DAO requires to operate effectively thus security remains a vulnerability as
it requires significant technical expertise and it is expensive to keep best security practices
implemented.
2. Slow Decision Making: With DAO scaling there comes an issue of getting everyone to vote
on proposals in a timely manner and with different time zones and investor priorities, keeping
DAO participants up to date can be challenging.
3. The Bikeshedding Effect: Parkinson’s Law of Triviality states that the amount of time spent
discussing an issue in an organization is inversely related to its importance in the scheme of
things. This is also known as bike-shedding. It can have a negative impact on personal
productivity as it causes inefficient management of time.
53
4. No legitimate structure for circulating DAOs: DAOs can be circulated across different
locales, and there’s no legitimate structure for them. Any lawful issues that might emerge
will probably require those required to manage various territorial laws in a convoluted fight
in court. In July 2017, for instance, the United States Securities and Exchange Commission
gave a report not really settled that the DAO sold protections as tokens on the Ethereum
blockchain without approval, disregarding bits of protection law in the country.
Future of DAO
The DAO as initially imagined had not returned as of mid-2020. Regardless, interest in
decentralized independent associations as a more extensive gathering keeps on developing.
While there are many waiting concerns and potential issues with respect to lawfulness, security,
and construction, a few investigators and financial backers accept that this kind of association
will ultimately come to conspicuousness, maybe in any event, supplanting customarily organized
organizations.
Criticism of DAO
There are likewise a couple of drawbacks to DAO:
1. One significant issue of being open-source is that securing business insider facts will end up
being more troublesome.
2. Additionally, potential hackers can more easily detect weak spots in the system as they can
openly access the source code. In rare cases, they could even slip their pieces of code into
the software without being detected by the community. That way they could create their own
loopholes.
What is Remix-IDE?
The Remix is an Integrated Development Environment(IDE) for developing smart contracts in
Solidity programming language. The IDE can be used to write, compile, and debug the Solidity
code. It was written in JavaScript and supports testing, debugging and deploying smart contracts,
and much more. Remix-IDE can be accessed in many different ways:
1. You can use it online in any browser of your choice, by entering the
URL: https://remix.ethereum.org/ in the browser.
2. Or you can install it in your own system using this link.
3. The third way is to use Mist (the Ethereum Dapp browser).
The JavaScript VM is a simulated Blockchain Environment that only exists in your browser. It
also only exists as long as you keep the browser-tab open. Close it or reload it, you start from
scratch.
On the positive side: it's super fast! No waiting for Transactions to be mined. No complicated
setup. It's just there and it works out of the box
54
On the negative side: There's only limited ways to connect to it. Once you reload everything is
gone (non persistant). Sometimes things in the browser simulation work, which won't work on a
real blockchain.
smart contract in solidity using remix-ide which is a browser-based IDE. So let’s get started
with our first simple “Hello World” program.
1. Open the remix-ide in your browser by typing: https://remix.ethereum.org/
2. You will be presented with following screen:
3. Click on the “file explorer” icon onto the left side bar (indicated by blue arrow in the
above picture).
4. Select Solidity in the Environment and click + symbol right to the browser.
5. Type the file name “HelloWorld.sol” and enter the following code into it
55
// My First Smart Contract
pragma solidity >=0.5.0 <0.7.0;
contract HelloWorld {
function get()public pure returns (string memory){
return 'Hello Contracts';
}
}
6. Once done click the icon just below the “file explorer” icon as shown below:
56
8. Once compiled successfully click the icon below “Solidity Compiler” that is “Deploy
and run transactions”. You will be welcomed by next screen:
9. Without changing any of the values as shown above just click “Deploy” button to deploy
your smart contract. Once deployed you will find your smart contract just below
contract HelloWorld{
57
string userInput;
11. After clicking the ‘>’ in the Deployed Contracts section a drop down menu will be opened
which will consist of two methods. Set and Get.
12. Now beside the set method we can see a blank box appears which asks for a string value.
Here we will type whatever we will like to print / show. Then click on set. In the terminal
user can see another transaction happened. Then click on get, and the string we passed
will be visible below.
58