Module 4 - Public Blockchain
Module 4 - Public Blockchain
Key Characteristics
2. Transparency: All transactions are visible to anyone who accesses the blockchain,
ensuring that data can be verified and audited by any participant.
3. Privacy Concerns: While transparency is a strength, it can also pose privacy risks.
All transactions are visible on the blockchain, which may expose sensitive user
information.
5. Vulnerability to Attacks: Although public blockchains are generally secure, they are
still susceptible to certain attacks, such as Sybil attacks or 51% attacks, where an
entity gains control over a majority of the network’s computational power.
Ethereum
● 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.
● Ethereum is often called Blockchain 2.0 since it proved the potential of blockchain
technology beyond the financial sector.
Features of Ethereum
Now, have a look at the features of Ethereum that make it so different from other
cryptocurrencies.
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.
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.
1. Mining Node –
These nodes are responsible for writing all the transactions that have occurred in the
Ethereum network in the block.
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 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.
Component-4 :
Ethereum Accounts –
There are two types of Ethereum accounts. They are as follows.
2. Contract account –
As the name itself suggests, these accounts store the details of Smart Contracts.
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.
Component-6 :
Storage Root –
It is the main root node of a Merkle tree. Hash of all details of the account is stored here. The
root of the Merkle tree is the verification of all transactions.
● Ethash
The intended PoW algorithm for Ethereum 1.0 is Ethash. It’s the most recent version
of Dagger-Hashimoto, however, it’s no longer proper to call it that because many of
the algorithms’ initial characteristics have been dramatically altered in the previous
month of study and development. Since ethereum transitioned to Proof of Stake (PoS)
in 2022, ethash has become legacy and the PoS Algorithm used is – “Clique”.
Component-8 :
Execution Client –
These are core components that act as the heart of ethereum, and facilitates transaction
processing, maintaining state, and ensuring every node is following the consensus rules. Here are
key responsibilities :-
● Keeping track of current state of the blockchain, syncing with the overall networks
that involves account balances, smart contract execution and block information
● Validating blocks and ensuring they adhere to the ethereum network’s agreed upon
rules
Component-9 :
Consensus Client –
A consensus client is a software that implements the Proof-of-Stake Algorithm and helps the
blockchain network ensure that all the nodes agree on the state of the blockchain. It has the
following key responsibilities :-
● Transaction Validation : Ensuring that any transaction made over the ethereum
network adhere to the rules and guidelines set
● Block Proposal: Block proposal is the process of organizing a set of valid transaction
into groups and then broadcasting them to the ethereum network for proposal as
including them in the network.
Algorithm:
The algorithm follows the following general path as follows.
1. There is a seed for each block that may be determined by reading over the block
headers till that point.
2. A 16 MB pseudo-random cache may be computed from the seed. The cache is saved
by light clients.
3. We can construct a 1 GB dataset from the cache, with the condition that each item in
the dataset is dependent on just a few cache items. The dataset is stored by full clients
and miners. The dataset expands linearly over time.
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.
Mining in Ethereum
Ethereum mining is a process that verifies new transactions in the Ethereum blockchain and their
addition to blocks combined with issuing the crypto coins.
The benefits of Ethereum mining include:
1. Security: Ethereum miners help to secure the network by verifying and adding transactions to
the blockchain.
2. Decentralization: Ethereum mining is a decentralized process, which means that anyone can
3. Earnings: Ethereum miners are rewarded with Ethereum for their efforts in verifying and
4. Potential: The Ethereum network is still in its early stages, and as it grows, so too will the
5. Participation: Ethereum mining is a great way to get involved in the Ethereum network and to
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.
● 2022: In 2022, Ethereum has shifted from PoW( Proof-of-Work ) to PoS( Proof-of-
State ) consensus mechanism, which is also known as Ethereum Merge. It has
reduced Ethereum’s energy consumption by ~ 99.95%.
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.
● 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.
Drawback of Ethereum
● Complicated programming language: Learning solidity from programming smart
contracts on Ethereum can be challenging and one of the main concerns is the scarcity
of beginner-friendly classes.
● Low transaction rate: Bitcoin has an average transaction rate of 7TPS and Ethereum
has an average speed of 15 TPS which is almost double that of bitcoin but it is still
not enough.
Bitcoin Ethereum is a
Definition (abbreviation: BTC; decentralized global
sign: ₿) is a
decentralized software platform
digital currency powered by blockchain
that can be technology. It is most
transferred on the commonly known for its
peer-to-peer native cryptocurrency,
bitcoin network. ether (ETH).
The Proof-of-Work
The Proof-of-Stake is the
Consensus (PoW) is the consensus
consensus mechanism
Mechanism mechanism used by the
used by Ethereum.
Bitcoin network.
Energy consumption is
Energy Energy consumption is
very low as compared to
Consumption very high.
bitcoin
Assets of Ethereum is
Assets Assets of Bitcoin is BTC.
Ether.
contracts.
execution of another.
Purpose of EVM
Here are the several key purposes of EVM:
1. Execution of Smart Contracts: The EVM is responsible for
trustless transactions.
transactions.
nodes.
3. Execution: Each node runs its own instance of the EVM to execute
the transaction. The EVM processes the contract logic and updates
4. Gas Mechanism: Each operation consumes gas, which users pay for.
If the transaction runs out of gas, it reverts, but the gas is still spent.
publicly verifiable.
Architecture of the EVM
Here is an overview of the architecture of EVM:
Stack-Based Architecture: The EVM operates using a stack where data is
pushed and popped. Each stack can hold up to 1024 items, enabling
● Stack: A list of 32-byte items utilized for holding the inputs and outputs of smart
contract instructions
● Memory: Temporary data that is used during contract execution
● Storage: Mapping of 32-byte slots to 32-byte values containing keys like nonce,
Figure :- Memory
2. Stack: The Stack enables the EVM to execute code and transaction instructions,
ultimately updating the world state of Ethereum. The Stack is part of the volatile machine
state of the EVM, so its operations are only persistent during transaction execution. The
Stack is also limited in its operations and computing, so any operations exceeding the
limits will result in a Stack error, causing a transaction to revert. In size, the Stack is
limited to 1024 elements in total and uses words, which are 256-bit, 32-byte chunks of
data. The Stack cannot store values such as arrays, strings, or mappings, so other
components like Memory can be used to store them for reference during transaction
execution. A common error developers run into when dealing with the Stack is stack
overflow/underflow and not enough gas. This occurs when there is an exception on the
Stack due to an incorrect amount of items on the Stack or insufficient gas to complete the
computation.The Stack is designed in a Last-In First-Out (LIFO) data format and
executes different bytecodes (opcodes) by popping values off the stack, executing the
bytecode, and then pushing them back on the Stack. Basic operations of the Stack include
opcode instructions like PUSH1, ADD, MUL, POP (and more), which all rely on the
Stack to perform. The Stack can also access other parts of the VM, such as Memory and
Storage (i.e., world state), which reference opcodes such as MSTORE and SSTORE, both
of which we'll cover later.
Figure :- Stack
3. Storage:-The world state (aka Storage) of Ethereum is persistent, unlike the Stack and
Memory, which are volatile. Storage consists of a keystore of 256-bit to 256-bit values
that contain different states of an account (smart contract) such as balance, nonce, storage
hash and code hash. Accounts that are externally owned (EOA; e.g., non-custodial
wallets) only contain balance and nonce key stores. Storage uses a modified Merkle
Patricia Trie data structure to store accounts (EOA and smart contracts) via hashing and
reducing the stored data to a single root hash. This hash represents a mapping between
account addresses and account states (e.g., balance, nonce, storage hash, code hash).
The Storage component of the EVM enables the state to be persistent and modifiable,
enabling use cases like updating the token balance of an account. Storage can be accessed
via a message call; this is with methods such as eth_call, which is one of the RPC
methods on Ethereum implementations like Geth. The cost of Storage on Ethereum is
paid via transaction execution, consisting of fees to validators (which can vary on
network activity) and the predetermined gas costs for each opcode. Since Storage on
Ethereum can get expensive, others look for solutions like IPFS and AWS to store data
(e.g., NFT Metadata). Check out our IPFS guides to learn how to pin data on the IPFS
network via a UI or API.
4. EVM Code:-Smart contracts are written in higher-level languages like Solidity and Vyper
and eventually get compiled down to bytecode (EVM Code). This bytecode (smart
contract instruction) is stored in Storage (in the account state fields) and can be accessed
by other smart contracts and EOAs to read or interact with.
5. Program Counter (PC):-With the smart contract instructions from the compiled EVM
code, the Program Counter tracks the EVM instruction (opcode) to execute next, ensuring
operations are done in the correct sequence.For example, if the bytecode of a smart
contract is 20 bytes long, you should expect to have 20 lines, and each line will be an
opcode instruction.
6. Gas:-Gas can be thought of as the fuel needed for transactions to be executed via the EVM. It
is a unit that measures the computational effort required to execute operations. Each opcode
executed by the EVM consumes a certain amount of gas, predetermined by the Ethereum yellow
paper. The implementation of gas prevents spam (DDos) and ensures that resources are used
efficiently.
2. State Management: The EVM maintains the global state of all accounts and
contracts, ensuring that data is consistent and accessible across the network.
5. Distributed Network: Both the EVM and the Ethereum blockchain operate on a
decentralized network of nodes, meaning no single entity controls the system,
enhancing security and trust.
1. Languages
1. Solidity: The most widely used language for writing smart contracts. It’s similar to
JavaScript and designed specifically for Ethereum.
1. Remix: A web-based IDE that allows developers to write, test, and deploy smart
contracts easily.
2. Truffle: A popular framework that provides a suite of tools for developing, testing,
and deploying DApps, including a built-in testing environment and migration scripts.
1. Unit Testing: Writing tests for smart contracts to ensure they function as intended.
Frameworks like Truffle and Hardhat provide testing libraries.
2. Debugging Tools: Tools like Remix and Hardhat offer debugging capabilities to trace
errors in smart contracts during development.
4. Deployment
1. Web3.js: A JavaScript library that allows web applications to interact with the
Ethereum blockchain, enabling communication with smart contracts.
7. Deployment to Mainnet
Once contracts are thoroughly tested and audited, they can be deployed to the Ethereum mainnet,
where they will operate in a live environment.
Benefits of EVM
1. Execute Untrusted Code: One can execute untrusted code without putting the data at
risk. EVM guarantees that its computations will not interfere with anything else
happening in the system or with the personal files.
2. Execute Complex Smart Contracts: One can run complex smart contracts in EVM
without worrying about how they interact with each other. One can write them once
and then run them on multiple platforms, which allows for the creation of a single
contract that runs on multiple computing environments.
5. Robust Against Failure: This is a complex process because the network needs to be
able to come to a consensus at any given time. This way, the system becomes more
robust against failures of individual nodes and you can update several nodes
simultaneously without worrying that they might end up disagreeing with each other
because of how code was written.
Limitations of EVM
1. High Cost of Storing Data: First is gas, which is what you need to use to pay the fee
to run a smart contract, and the other is the high cost of storing data on the
blockchain, which could take up more than 3TB
2. High Gas Cost: In Ethereum, all transactions require a fee to execute. These fees are
called “gas”, and are paid in ETH tokens. Gas is priced at the moment of execution,
and depends on the complexity of executing a transaction. The more difficult the
computation for a transaction, the higher its gas cost will be.
3. High Gas Price During Network Congestion: During times when there is high
network congestion due to many transactions being pushed onto the blockchain, gas
prices rise because there are fewer transactions that can go through (the same amount
of computational power has to service more transactions).
4. Technical Expertise Required: Writing smart contracts and using EVM requires
technical expertise. It’s a Turing-complete system, which allows programmers to
write scripts in any programming language they wish. This can be excellent or
disastrous, depending on the intention behind the code being written. Programming
languages are not inherently good or bad; it all depends on who is using them and for
what purpose. The downside of this technology is that it could create a lot of
complicated problems because with more power comes more responsibility for the
writer of code.
Steps to Transfer Ether (ETH) using MetaMask:
STEP 1: Open Metmask. If this is your first time you install Metamask , you will be asked to
create your first password for encrypting your wallet.
Figure 1–1: Create new wallet:- If you already stored your Mnemonic Phrases somewhere else
before, you can restore all of your wallets by choosing “Import Existing DEN”, then paste the 12-
words Mnemonic Phrases into the “Wallet Seed” box.
After create/restore your Metamask DEN, you will see your wallet(s) appear in Metamask.
Figure 1–3: Account details
Step 2: For sending ETH into an address, click “SEND” button. Put the destination address and
amount of ETH then click “NEXT”