0% found this document useful (0 votes)
43 views20 pages

Unit Iv

blockchain tchnology pdf

Uploaded by

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

Unit Iv

blockchain tchnology pdf

Uploaded by

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

Unit- IV

Blockchain Components & Consensus

Introduction of Ethereum:
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). The Ethereum network is fueled by its own
cryptocurrencies called ‘ether’.
 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.
 The consensus mechanism used in Ethereum is Proof of Stakes(PoS), which is
more energy efficient when compared to that used in the Bitcoin network, that
is, Proof of Work(PoW). PoS depends on the amount of stake a node holds.

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 cryptocurrencies 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.

Type of Ethereum Accounts

Ethereum has two types of accounts: An externally owned account (EOA), and a
Contract account. These are explained as following below:

 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.
 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.

History:
 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-State ) consensus mechanism, which is also known as Ethereum
Merge. It has reduced Ethereum energy consumption by ~ 99.95%.

Ethereum Virtual Machine:

Introduction to Ethereum Virtual Machine (EVM)?


Ethereum Virtual Machine (EVM) is designed as the runtime environment
for smart contracts in Ethereum. It is sandboxed and isolated from the other parts
of the system. This means that any operation on EVM should not affect your data
or programs in any way, no matter how many times you call a particular function
on it.
 An EVM is the runtime environment that executes Ethereum smart contracts.
 Ethereum contains its own Turing-complete scripting language, called Solidity,
and with this comes a need to execute this code.
 A program called the Ethereum Virtual Machine (EVM) can do this task.
 It runs on top of the Ethereum network, meaning that all nodes reach a
consensus about what code should be executed at every given time.

Purpose of EVM

The Ethereum Virtual Machine (EVM) is a Turing complete


programmable machine, which can execute scripts to produce arbitrary outcomes.
It has been built with the purpose of being a “world computer” and has immense
power.

 It is the computer that stores data on blockchain, like bitcoin, but it also executes
code in smart contracts on the Ethereum network.
 The machine is made to be able to run any kind of Crypto-contract that can be
built on Ethereum blockchain. It does this by using a programming language
called Solidity, which is compiled into the EVM for execution.
 The intention behind writing code on the Ethereum network is to create smart
contracts and programs that automatically execute things when certain
conditions are met. If a terms or condition is not met, the system can execute it
in an “exit” function as well.
 For example, if an account has been hacked, the hacker cannot steal money from
the system, because they don’t have the budget or authority to do so.

How Does EVM Works?

Ethereum Virtual Machine (EVM) is a program which executes scripts used to


implement certain operations usually in Ethereum blockchain.
The Ethereum Virtual Machine makes the process of creating new tokens on
Ethereum Blockchain easy. Here, script means a set of instructions or an algorithm
which tells the computer what it needs to do in order for something to work
properly. The EVM requires that one has access over any network node so as to be
able to execute the desired commands and create new tokens on the blockchain
without any difficulties.

 In Ethereum, there is something called a smart contract. These contracts have


some computer code which facilitates the exchange of money and information.
 These contracts are predefined by the creator of the smart contract, in order to
ensure that a certain outcome will happen based on either what happens or
doesn’t happen.
 Ethereum Virtual Machine provides Turing complete environment for
execution of scripts and smart contracts. This means that anything that can be
implemented with a computer can be run on EVM.
In the Ethereum ecosystem, EVM plays a vital role by providing a platform for
decentralized applications (DApps) to be built on top of it.
Ethereum Virtual Machine ensures that all transactions and smart contracts made
on the Ethereum blockchain are executed in correct and expected manner as desired
by the smart contract code. It serves as a platform for applications to be executed
on.
In simple words, it can be said that Ethereum Virtual Machine facilitates DApp
creation and execution on the blockchain.
Ethereum Virtual Machine (EVM) has two parts:
 EVM (the part that runs solidity source code): The EVM is written in C++
and uses LLVM as its compiler. It is a full-featured virtual machine with all the
features that you would want in a general purpose Smart Contract Virtual
Machine, such as support for multiple programming languages, security
features, runtime environments and more. It also allows you to write custom
EVM byte code.
 Uncles: These are small pieces of smart contracts or data stored on the
blockchain. This is a useful feature because it allows for you to store metadata
about your program. EVM Assembly: This is the byte code of EVM, which you
can use as your programming language.
These are small pieces of smart contracts or data stored on the blockchain. This is
a useful feature because it allows one to store metadata about the program.
 Actions: These are basic operations that one can perform on assets stored in
memory (and not on the blockchain), such as multiplication, addition, and so
on.
 Balance: This is the amount of Ether that one have at any time. So, if there is a
balance of 100 Ether and spend 10 Ether, the balance would be 90 Ether. Note
that this is not actually a variable, it’s just a part of memory where EVM stores
the data. This means that when one tries to modify or read from it, it will return
execution with an error.
 Block: This is an immutable storage for all actions and transactions related to
Ethereum in its lifetime up until this block in particular. These blocks can be
only 65,000 so this is not going to change.
 Blockhash: This is a hash of the block in question. So, if you are looking at
stored on the blockchain under another name, this would be a hash of the data
stored there.
 Block Number: This is a number indicating which block this particular
blockhash belongs to. It always starts from zero and increases every time there’s
a new block added to the chain. Note that blocks have timestamps associated
with them so you can tell how much time passed between two blocks.
 Code: This is code executed in EVM that determines what action is going to be
taken when an input happens (such as transferring money).
 CodeHash: This is a hash of the code itself. If one looks at a contract on Ether
scan, the Code Hash is what one will see. When functions are executed on EVM,
this number changes because the code itself changes based on the input.
 CodeSize: This is the actual size of the code in bytes.
 GasLimit: This is a part of EVM that allows for users to specify how much gas
they are willing to spend in order to execute something. If this number is zero,
then nothing will happen (this rarely happens).

Benefits of EVM

 Execute untrusted code without risking data: 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.
 Can run 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.
 Deterministic processing: Smart contracts written on EVM have access to all
of Ethereum states at any given time, allowing for processing to happen in a
deterministic way and giving more guarantees about their correctness. For
example, one cannot make an infinite loop in EVM by calling the same function
twice. It would stop executing and return a finite value.
 Distributed consensus: One of the potential applications of Ethereum is to
allow for distributed consensus where everyone is running the same program
but from their own computers.
 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.
 Easy to write stateful contracts: From a developer perspective, EVM is
designed for writing smart contracts as well as for creating DApps
(decentralized applications), which are programs running on distributed
networks in a way that ensures all of them are seeing the same version. It also
makes it incredibly easy to write stateful contracts, which need access to some
kind of persistent storage.

Downsides of EVM

 High cost of storing data: First is gas, which is what you need to use in order
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
 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.
 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).
 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 in their nature;
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.

Working of Ethereum:
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.
 Every transaction must include:
 Gas limit.
 Transaction Fee that the sender is willing to pay for the transaction.
 If the total amount of gas needed to process the transaction is less than or
equal to the gas limit then the transaction will be processed and if the total
amount of the gas needed is more than the gas limit then the transaction will
not be processed the fees are still lost.
 Thus it is safe to send transactions with the gas limit above the estimate to
increase the chances of getting it processed.

Real-World Applications of Ethereum

 Voting: Voting systems are adopting Ethereum. The results of polls are
available publicly, ensuring a transparent fair system thus eliminating voting
malpractices.
 Agreements: With Ethereum smart contracts, agreements and contracts can be
maintained and executed without any alteration. Ethereum can be used for
creating smart contracts and for digitally recording transactions based on
them.
 Banking systems: Due to the decentralized nature of the Ethereum blockchain
it becomes challenging for hackers to gain unauthorized access to the network.
It also makes payments on the Ethereum network secure, so banks are using
Ethereum as a channel for making payments.
 Shipping: Ethereum provides a tracking framework that helps with the
tracking of cargo and prevents goods from being misplaced.
 Crowd funding: Applying Ethereum smart contracts to blockchain-based
crowd funding platforms helps to increase trust and information symmetry. It
creates many possibilities for startups by raising funds to create their own
digital cryptocurrencies.
 Domain names: Ethereum name service allows crypto users to buy and
manage their own domain names on Ethereum, thus simplifying decentralized
transactions without putting users to remember long, machine-readable
addresses .
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

 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.
 Volatile cryptocurrencies: Ethereum investing can be risky as the price of
Ether is very volatile, resulting in significant gains as well as a significant
loss.
 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.

Ethereum Clients:
There are 3 types of Ethereum Clients
1. Full Client: Full clients save the complete Ethereum blockchain, which might
take several days to synchronize and takes a massive amount of disc space –
more than 1 Terabyte, according to the most recent estimates. Full clients enable
connected nodes to conduct all network functions, including as mining,
transaction and block-header validation, and smart contract execution.
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.

Ethereum Node vs. Ethereum Client

SR.
No. Ethereum Node Ethereum Client
A client is an Ethereum
A machine running Ethereum implementation that validates all
1. client software is referred to as an transactions in each block,
“Ethereum Node”. ensuring the network’s security
and data accuracy.
The three types of Ethereum The three types of Ethereum
2. Nodes are Full, Light, Archive, Clients are Full, Light, and
and Miner Nodes. Remote Clients.
The Ethereum node operating The Ethereum client computer
3. system allows us to access the allows a user to access the node
internet. operating system.

Ethereum Key Pairs:


Ethereum, like many other blockchain platforms, uses cryptographic key pairs to
provide security and enable various functions such as sending and receiving Ether
(ETH), interacting with smart contracts, and managing user accounts. These key
pairs consist of two components: a private key and a public key. Here's an
overview of Ethereum key pairs:

Private Key:
The private key is a long, randomly generated alphanumeric string (usually 64
characters in hexadecimal format).It must be kept secret and should only be known
to the owner of the Ethereum account. The private key is used to sign transactions
and access the associated Ethereum address.
Public Key:
The public key is derived from the private key using a cryptographic process.
It is a shorter string that is used as the recipient's address when receiving Ether or
interacting with smart contracts on the Ethereum network. The public key is
mathematically related to the private key but cannot be used to determine the private
key. It can be shared freely with others, as it is not sensitive information.
Ethereum Address:
An Ethereum address is a 40-character hexadecimal string derived from the public
key. It serves as the recipient's address for receiving Ether and tokens, as well as for
identifying accounts on the Ethereum blockchain.
Ethereum addresses are used in transactions and are publicly visible on the
blockchain.
Here's how Ethereum key pairs are typically used:
Account Creation: When a user creates an Ethereum account, a private key is
generated randomly, and the corresponding public key and Ethereum address are
derived from it.
Transaction Signing: To send Ether or interact with smart contracts, the owner of an
Ethereum account signs a transaction using their private key. This cryptographic
signature proves ownership and authorizes the transaction.
Address Verification: When someone wants to send Ether to your Ethereum
account, they use your Ethereum address as the destination. The recipient's public
key (derived from the address) is used to verify the transaction's legitimacy.
Access and Control: Control of an Ethereum account (including any Ether or
tokens associated with it) is determined by the possession of the private key.
Whoever has access to the private key has control over the associated account.
It's crucial to keep the private key secure and never share it with anyone you don't
trust. Losing the private key means losing access to the associated Ethereum
account and any assets stored in it. Many wallet applications and hardware devices
are available to help users manage and secure their Ethereum key pairs.
Additionally, some wallets provide recovery phrases (mnemonic phrases) as a
backup mechanism in case the private key is lost, allowing users to regenerate their
private key and access their accounts.
Ethereum Addresses:
Ethereum addresses are fundamental components of the Ethereum blockchain,
serving as identifiers for user accounts, smart contracts, and other entities within
the network. These addresses are hexadecimal strings that are used for sending and
receiving Ether (ETH), as well as interacting with smart contracts. Here are some
key points about Ethereum addresses:
Format: Ethereum addresses are 40-character hexadecimal strings, often
represented in lowercase. They consist of the characters 0-9 and a-f. For example:
0x742d35Cc6634C0532925a3b844Bc454e4438f44e.
Prefix: Ethereum addresses typically start with "0x" to indicate that they are
hexadecimal and compatible with Ethereum address format.
Derived from Public Key: Ethereum addresses are derived from the corresponding
public key, which is itself derived from the private key. This derivation involves a
one-way cryptographic process. While it is possible to determine the public key
from the address, it is computationally infeasible to determine the private key from
the address or the public key.
Types of Addresses:
Externally Owned Accounts (EOA): These addresses are associated with
individual users and are used for holding and managing Ether. EOAs are controlled
by private keys.
Contract Addresses: These addresses represent smart contracts deployed on the
Ethereum blockchain. They are created when a contract is deployed and have the
same format as user addresses. However, they do not have corresponding private
keys and cannot be used to initiate transactions. Instead, transactions to contract
addresses trigger the execution of the associated smart contract code.
Checksum Addresses: Ethereum addresses also include a checksum to help prevent
typos when entering addresses. This feature ensures that a valid address is entered
by verifying the integrity of the hexadecimal characters and their case
(lowercase/uppercase).
Interoperability: Ethereum addresses can be used in various Ethereum-based
applications, such as wallets, exchanges, and decentralized applications (DApps).
They are also used for receiving tokens and NFTs (non-fungible tokens) in addition
to Ether.
Public Visibility: Ethereum addresses and their associated transactions are public
and can be viewed on blockchain explorers. However, the identities of the address
owners are typically pseudonymous unless revealed through other means.
Security: It's crucial to safeguard your Ethereum address and associated private key.
Losing access to the private key means losing control over the Ether and assets
associated with that address. Many users choose hardware wallets, software wallets,
or secure storage methods to protect their private keys.
In summary, Ethereum addresses are unique identifiers within the Ethereum
blockchain and are used for various purposes, including sending and receiving Ether,
interacting with smart contracts, and participating in decentralized applications.
Users should handle their addresses and associated private keys with care to maintain
control over their assets on the Ethereum network.
Ethereum Wallets:
Ethereum wallets are software or hardware tools that allow users to manage their
Ether (ETH), interact with smart contracts, and store various Ethereum-based assets.
These wallets enable users to securely store their private keys, which are necessary
for signing transactions and controlling their Ethereum accounts. There are several
types of Ethereum wallets available, each with its own features, security levels, and
use cases:
Software Wallets:
Desktop Wallets: These are wallet applications that you install on your computer.
They offer a user-friendly interface and can be a good choice for users who want to
manage their Ethereum assets on a personal computer. Examples include Exodus,
MyEtherWallet (MEW), and Atomic Wallet.
Mobile Wallets: Mobile wallets are designed for smartphones and tablets. They
provide convenience and are suitable for users who want to manage their Ether on
the go. Popular mobile wallet apps include Trust Wallet, Coinbase Wallet, and
Coinomi.
Web Wallets: Web wallets are accessible through a web browser and do not require
installation. While they offer convenience, users should be cautious about the
security of the website and ensure they are using reputable services. MyEtherWallet
(MEW) offers both a web and desktop version.
Hardware Wallets:
Hardware wallets are physical devices that store your private keys offline, providing
a high level of security. They are immune to most types of online attacks and are a
recommended choice for long-term storage of significant amounts of Ether. Notable
hardware wallets include Ledger Nano S, Ledger Nano X, and Trezor.
Paper Wallets:
A paper wallet involves generating a pair of Ethereum addresses (public and private
keys) and printing them on paper or saving them as a physical medium (e.g., metal
engraving). Paper wallets are offline and provide a secure way to store Ether, but
they require careful handling to prevent loss or damage.
Multi-Signature Wallets:
Multi-signature wallets require multiple private keys to authorize a transaction. This
can be useful for businesses and organizations, as it adds an extra layer of security
and requires multiple parties to approve transactions.
Browser Extensions:
Some wallet services offer browser extensions that integrate with web browsers like
Chrome or Firefox. These extensions allow users to interact with Ethereum-based
websites and DApps seamlessly. Examples include MetaMask and Fortmatic.
Full Node Wallets:
Full node wallets download and synchronize the entire Ethereum blockchain,
providing maximum security and decentralization. However, they are resource-
intensive and require significant storage space and bandwidth. Geth and Parity are
popular full node software implementations.
Mobile DApp Browsers:
Some mobile wallets also function as decentralized application (DApp) browsers,
allowing users to access and interact with Ethereum-based DApps directly from their
mobile devices. Trust Wallet, Coin base Wallet, and Meta Mask Mobile offer DApp
browser functionality.
When choosing an Ethereum wallet, consider factors such as security, convenience,
your level of technical expertise, and the specific use case. It's crucial to back up
your private keys or wallet recovery phrases securely and never share them with
anyone. Additionally, regularly update and maintain your wallet software to ensure
the latest security features and bug fixes are in place.
Ethereum Transactions:
Ethereum transactions are at the core of how the Ethereum blockchain operates.
They are the actions that users or smart contracts initiate to interact with the
Ethereum network. Here's an overview of Ethereum transactions:
What is an Ethereum Transaction?
An Ethereum transaction is a signed message sent by an externally owned account
(EOA) or a smart contract to another account on the Ethereum network.
Transactions can transfer Ether (ETH), the native crypto currency of the Ethereum
network, or they can execute smart contract functions.
Components of a Transaction:
Sender (From): The account initiating the transaction, which can be an externally
owned account (controlled by a user) or a smart contract.
Recipient (To): The account to which the transaction is sent. If it's a contract
interaction, this will be the address of the smart contract.
Value: The amount of Ether (ETH) being transferred in Wei (1 ETH = 10^18 Wei).
If the transaction is interacting with a contract, the value can be zero.
Data: For contract interactions, this field contains the function call and parameters
encoded as byte code.
Gas Limit: The maximum amount of gas units that the sender is willing to spend on
the transaction.
Gas Price: The price (in Wei) the sender is willing to pay for each gas unit. This
determines the transaction fee.
Nonce: A unique number for each transaction sent from the sender's account, used
to prevent double-spending.
Transaction Processing:
When a transaction is submitted to the Ethereum network, it is first verified for
correctness and signature. The transaction is added to the transaction pool
(mempool) and waits to be included in a block. Miners select transactions from the
pool and package them into blocks. The miner of a block validates the transactions
and adds them to the blockchain. The sender's account balance is adjusted based on
the result of the transaction's execution (e.g., transfers or smart contract state
changes).If the transaction runs out of gas during execution, all changes are reverted,
but the gas is still consumed.
Transaction Confirmation:
Once a transaction is included in a block, it is considered confirmed.
It is advisable to wait for multiple confirmations (usually 12 or more) to ensure the
transaction is securely settled in the Ethereum blockchain.
Transaction Fee:
Transaction fees are paid to miners in the form of Ether and are used to incentivize
them to include transactions in a block.
The total transaction fee is calculated as the product of the gas price and the gas used
in the transaction.
Failed Transactions:
If a transaction encounters an issue during execution (e.g., insufficient gas, invalid
recipient), it fails, and any changes are reverted. The sender still pays the gas fee for
the attempted execution.
Ethereum Languages:
Ethereum is a blockchain platform that allows developers to build and deploy
decentralized applications (DApps). To develop smart contracts and DApps on the
Ethereum platform, you typically use a variety of programming languages. Here are
some of the key languages and tools used in Ethereum development:
Solidity: Solidity is the most popular and widely used programming language for
Ethereum smart contract development. It is specifically designed for writing smart
contracts on the Ethereum platform. Solidity is a statically-typed language with a
syntax similar to JavaScript. Smart contracts written in Solidity are compiled into
bytecode that can be executed on the Ethereum Virtual Machine (EVM).
Vyper: Vyper is another programming language for Ethereum smart contracts. It's
designed to be more readable and Pythonic in nature, making it a good choice for
developers who are more comfortable with Python. Vyper code is also compiled into
EVM bytecode.
Serpent: Serpent was an earlier language used for Ethereum smart contracts. It has
been largely replaced by Solidity and Vyper, but some legacy contracts may still use
it.
LLL (Low-Level Lisp-like Language): LLL is a low-level language for Ethereum
smart contract development. It provides more control over the EVM and is typically
used for very low-level optimization.
Bamboo: Bamboo is a language designed for Ethereum smart contracts that focuses
on security and simplicity. It's a high-level language that compiles down to Solidity.
Yul: Yul is a low-level intermediate language for the Ethereum Virtual Machine. It
is used to write low-level code that can be compiled to EVM bytecode. Developers
may use Yul for optimizing gas costs in their smart contracts.
Rust: Although not specific to Ethereum, Rust is a systems programming language
that can be used to build Ethereum smart contracts through the use of the Ink! Frame
work. This allows developers to write smart contracts in Rust and compile them to
Ethereum-compatible code.
Web3.js: While not a programming language, Web3.js is a JavaScript library that
allows developers to interact with the Ethereum blockchain using JavaScript. It's
commonly used for building web applications that interact with Ethereum.
Truffle and Hardhat: These are development frameworks and build tools that help
Ethereum developers manage their projects, compile smart contracts, and deploy
them to the blockchain.
Each of these languages and tools serves different purposes and caters to various
developer preferences. The choice of language depends on the specific requirements
of your project and your familiarity with the language. Solidity and Vyper are the
most widely adopted for Ethereum smart contract development.
Ethereum Development Tools Introduction:
Ethereum development tools are essential for creating decentralized applications
(DApps) and smart contracts on the Ethereum blockchain. Here is an introduction to
some of the key tools and frameworks used in Ethereum development:
Solidity: Solidity is the most popular programming language for Ethereum smart
contract development. It is a statically-typed, contract-oriented language with a
syntax similar to JavaScript. Solidity is used to write the logic for smart contracts
that are executed on the Ethereum Virtual Machine (EVM).
Vyper: Vyper is an alternative programming language for Ethereum smart contracts.
It is designed to be more readable and secure, with a Python-like syntax. Vyper is
used by developers who prefer a simpler and more human-readable language for
writing smart contracts.
Truffle: Truffle is a popular development framework for Ethereum. It provides a
suite of tools for smart contract development, including project scaffolding,
automated testing, and deployment scripts. Truffle also integrates with Ganache, a
personal Ethereum blockchain for testing and development.
Hardhat: Hardhat is another development framework for Ethereum that offers a
wide range of features for smart contract development. It includes a development
blockchain, task automation, and testing utilities. Hardhat is known for its
extensibility and integration with other tools.
Remix: Remix is an online IDE (Integrated Development Environment) for
Ethereum smart contract development. It offers a browser-based code editor,
compiler, debugger, and testing tools. Remix is convenient for quick smart contract
development and testing without the need for local installations.
Web3.js: Web3.js is a JavaScript library that allows developers to interact with the
Ethereum blockchain from web applications. It provides functions to send
transactions, query data, and interact with smart contracts from a web browser or
server-side JavaScript applications.
Ethers.js: Ethers.js is an alternative JavaScript library for Ethereum that is known
for its ease of use and modern design. It simplifies working with Ethereum by
providing a clean and well-documented API.
Infura: Infura is a service that provides Ethereum API access for developers. It
allows developers to connect to the Ethereum network without running their own
Ethereum nodes, making it easier to interact with Ethereum from web and mobile
applications.
Metamask: Metamask is a popular Ethereum wallet and browser extension that
allows users to manage their Ethereum accounts, interact with DApps, and sign
transactions. Developers often use Meta mask for testing and interacting with their
DApps during development.
Ganache: Ganache is a personal blockchain for Ethereum development. It provides
a local blockchain environment for testing smart contracts and DApps without the
need to connect to the main Ethereum network. It is often used in conjunction with
development frameworks like Truffle and Hardhat.
These tools and frameworks simplify and streamline the Ethereum development
process, from writing smart contracts to deploying and interacting with decentralized
applications. Depending on your preferences and project requirements, you may
choose different tools to suit your needs in Ethereum development.
Consensus Introduction:
Consensus Approach:
Consensus approaches are the methods or algorithms used in distributed systems,
particularly in blockchain technology, to achieve agreement among multiple
participants or nodes on the state of the network and the validity of transactions.
Here are some common consensus approaches:
Proof of Work (PoW):
In PoW, participants (miners) solve complex cryptographic puzzles to add new
blocks to the blockchain. The first one to solve it gets the right to add the block.
PoW is energy-intensive but provides high security and is the consensus mechanism
used in Bitcoin.
Proof of Stake (PoS):
PoS is based on the amount of cryptocurrencies a participant holds and is willing to
"stake" as collateral. Validators are chosen to create new blocks based on their stake.
PoS is more energy-efficient compared to PoW and is used in blockchains like
Ethereum 2.0.
Delegated Proof of Stake (DPoS):
In DPoS, token holders vote for a small number of delegates who are responsible for
validating transactions and creating new blocks.
DPoS aims to combine the decentralization of PoW with the efficiency of PoS and
is used in blockchains like EOS.
Proof of Authority (PoA):
PoA relies on a set of approved validators or authorities who have the right to
validate and add new transactions to the blockchain.
It's commonly used in private or consortium blockchains where the participants are
known and trusted.
Practical Byzantine Fault Tolerance (PBFT):
PBFT is a consensus algorithm used in some permissioned blockchains. It allows a
network to continue functioning even when some nodes are faulty or malicious.
PBFT is fast and efficient but often not as decentralized as PoW or PoS.
Proof of Space (PoSpace):
PoSpace relies on participants dedicating storage space on their devices to earn the
right to add blocks to the blockchain. It's a more eco-friendly approach compared to
PoW.
Proof of History (PoH):
PoH is used in the Solana blockchain and is designed to create a historical record of
events in the network that helps in achieving consensus quickly.
Hybrid Approaches:
Some blockchains use a combination of consensus mechanisms to balance the need
for security, scalability, and energy efficiency. For example, Algorand combines
PoS and PoA.
Future Consensus Mechanisms:
The blockchain space continues to evolve, and new consensus mechanisms and
algorithms are being researched and developed to address scalability, energy
efficiency, and security concerns.
The choice of consensus approach depends on the specific goals and requirements
of a blockchain network. Public blockchains, where participants may not trust each
other, often prioritize security, while private and consortium blockchains may
prioritize performance and efficiency. The consensus approach has a significant
impact on the blockchain's characteristics, including decentralization, scalability,
and energy consumption.
Consensus Algorithms:
Consensus algorithms are fundamental to the operation of distributed systems and
blockchain networks. They help nodes or participants in the network agree on the
state of the ledger and validate transactions. Here are some common consensus
algorithms:
Proof of Work (PoW):
PoW is the consensus algorithm used in Bitcoin. Miners compete to solve complex
mathematical puzzles, and the first to solve it gets to add a new block to the
blockchain.
PoW is energy-intensive but highly secure.
Proof of Stake (PoS):
PoS selects validators to create new blocks based on the amount of cryptocurrency
they "stake" as collateral. The more tokens staked, the higher the chance of being
chosen.
PoS is more energy-efficient compared to PoW.
Delegated Proof of Stake (DPoS):
In DPoS, token holders vote for a small number of delegates who have the authority
to produce blocks and validate transactions.
DPoS aims to combine the decentralization of PoW with the efficiency of PoS and
is used in blockchains like EOS.
Proof of Authority (PoA):
PoA relies on a set of approved validators or authorities who have the right to
validate and add new transactions to the blockchain.
It's commonly used in private or consortium blockchains where participants are
known and trusted.
Practical Byzantine Fault Tolerance (PBFT):
PBFT is a consensus algorithm used in some permissioned blockchains. It's designed
for high performance and can handle nodes that may fail or act maliciously.
Tendermint:
Tendermint is a Byzantine Fault Tolerant (BFT) consensus algorithm used in
blockchain platforms like Cosmos. It combines PoS with BFT for fast, secure, and
efficient consensus.
Raft:
Raft is another BFT-based consensus algorithm that is not specific to blockchain but
is used in distributed systems. It's designed for simplicity and ease of understanding.
HoneyBadgerBFT:
HoneyBadgerBFT is a relatively recent BFT-based consensus algorithm designed
for achieving consensus in asynchronous networks with minimal assumptions.
Avalanche:
Avalanche is a family of consensus protocols that aims to provide fast and scalable
consensus. It allows nodes to agree on a decision quickly without waiting for a
majority.
Proof of Space (PoSpace):
PoSpace relies on participants dedicating storage space on their devices to earn the
right to add blocks to the blockchain. It's energy-efficient compared to PoW.
Proof of History (PoH):
PoH is used in the Solana blockchain and is designed to create a historical record of
events in the network that helps in achieving consensus quickly.
Hybrid Approaches:
Some blockchains use a combination of consensus mechanisms to balance security,
scalability, and energy efficiency. For example, Algorand combines PoS and PoA.
The choice of consensus algorithm depends on the specific goals and use case of the
blockchain. Public blockchains often require a high level of security, while private
and consortium blockchains may prioritize performance and efficiency. Each
consensus algorithm has its trade-offs in terms of security, energy consumption, and
decentralization, and it's important to select the one that best suits the requirements
of the network.
Byzantine Agreement Methods:
Byzantine agreement methods, often referred to as Byzantine Fault Tolerant (BFT)
algorithms, are a class of consensus algorithms designed to enable distributed
systems to reach an agreement even when some participants are malicious or faulty.
These methods are crucial for ensuring the reliability and security of decentralized
networks, including blockchain systems. Here are some Byzantine agreement
methods:
Practical Byzantine Fault Tolerance (PBFT):
PBFT is one of the most well-known BFT algorithms. It's used in permissioned and
private blockchains and distributed systems.
It allows a network of nodes to reach consensus, even when a certain number of
nodes are Byzantine (malicious) or fail.
HoneyBadgerBFT:
HoneyBadgerBFT is a more recent BFT algorithm known for its robustness and
asynchronous consensus properties.
It's designed for use in decentralized networks and is tolerant of a large number of
adversarial nodes.
Algorand:
Algorand employs a consensus mechanism that combines PoS and BFT-like
processes to achieve rapid and secure agreement.
It's known for its efficiency and security, making it suitable for various decentralized
applications.
Tendermint:
Tendermint is a BFT-based consensus algorithm used in the Cosmos ecosystem. It
combines PoS with BFT for speed, security, and efficiency.
Raft:
Raft is not a blockchain-specific algorithm but is used in various distributed systems.
It's designed for simplicity and ease of understanding, making it a suitable choice
for less complex use cases.
HotStuff:
HotStuff is a BFT-based algorithm designed for use in blockchain networks. It's
known for its efficiency and fault tolerance.
Synchronous vs. Asynchronous Algorithms:
BFT algorithms can be categorized as synchronous or asynchronous, depending on
their assumptions about the timing of messages in the network.
Synchronous algorithms assume that messages are delivered within a known time
frame, while asynchronous algorithms work without such strict timing assumptions.
Hybrid Approaches:
Some blockchain platforms use hybrid consensus methods that combine BFT with
other algorithms, like PoS or PoW, to balance performance and security.
Byzantine agreement methods are particularly useful in permissioned blockchains,
consortium blockchains, and situations where participants are known and can be
trusted to some extent. They provide strong guarantees of consensus and are crucial
in scenarios where malicious actors or network failures must be tolerated without
compromising the integrity of the system. The choice of a Byzantine agreement
method depends on the specific use case, network requirements, and trade-offs
between performance and security.

You might also like