0% found this document useful (0 votes)
30 views

Unit 3 - Part 1

Ethereum is an open-source blockchain platform that enables developers to build decentralized applications and smart contracts. It supports smart contracts, decentralized applications, the Ether cryptocurrency, and uses the Ethereum Virtual Machine. Ethereum faces challenges around scalability, security, and regulatory compliance that it aims to address with upgrades like Ethereum 2.0.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Unit 3 - Part 1

Ethereum is an open-source blockchain platform that enables developers to build decentralized applications and smart contracts. It supports smart contracts, decentralized applications, the Ether cryptocurrency, and uses the Ethereum Virtual Machine. Ethereum faces challenges around scalability, security, and regulatory compliance that it aims to address with upgrades like Ethereum 2.0.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

CA576 BLOCKCHAIN COMPUTING

UNIT-III

ETHEREUM
Ethereum is a decentralized, open-source blockchain platform that enables developers to build and deploy
decentralized applications (DApps) and smart contracts. It was proposed by Vitalik Buterin in late 2013 and went
live on July 30, 2015. Ethereum aims to provide a platform for decentralized applications that is more flexible and
programmable than Bitcoin's blockchain.

With its robust features, active community, and ongoing development efforts, Ethereum continues to play a pivotal
role in shaping the future of decentralized finance, digital asset management, decentralized governance, and other
blockchain-enabled applications.

Key Features of Ethereum:


1. Smart Contracts: Ethereum's most notable feature is its support for smart contracts. Smart contracts are self-
executing contracts with the terms of the agreement directly written into code. They enable automated and
trustless execution of agreements, eliminating the need for intermediaries and enhancing security and
efficiency in various applications.
2. Decentralized Applications (DApps): Ethereum allows developers to build decentralized applications
(DApps) on its blockchain using smart contracts. DApps operate on a decentralized network of computers
(nodes), ensuring censorship resistance, immutability, and transparency. DApps can serve various purposes,
including decentralized finance (DeFi), gaming, supply chain management, and more.
3. Ether (ETH) Cryptocurrency: Ether (ETH) is the native cryptocurrency of the Ethereum platform. It serves
as a means of value transfer within the Ethereum ecosystem and is used to compensate network participants
who perform computations and validate transactions (miners and validators). Ether can also be used to pay
for transaction fees and access computational resources on the Ethereum network.
4. Turing-Complete Programming Language: Ethereum features a Turing-complete programming language
called Solidity, which is specifically designed for writing smart contracts. Solidity allows developers to
express complex business logic and create a wide range of applications, from simple token contracts to
sophisticated decentralized autonomous organizations (DAOs) and decentralized exchanges (DEXs).
5. Ethereum Virtual Machine (EVM): Smart contracts on Ethereum are executed on the Ethereum Virtual
Machine (EVM), a decentralized runtime environment that runs on every node in the network. The EVM
ensures that smart contracts are executed deterministically and securely across all nodes, regardless of their
underlying hardware or operating system.
6. Consensus Mechanism: Ethereum currently uses a proof-of-work (PoW) consensus mechanism, similar to
Bitcoin, to validate and add new blocks to the blockchain. However, Ethereum is in the process of
transitioning to a proof-of-stake (PoS) consensus mechanism with Ethereum 2.0. PoS is expected to improve
scalability, energy efficiency, and security on the Ethereum network.
7. Community and Governance: Ethereum has a vibrant and diverse community of developers, contributors,
users, and stakeholders who collaborate to develop and improve the platform. Decisions about the future
direction of Ethereum are made through community discussions, proposals, and consensus among
stakeholders.

Use Cases of Ethereum:


1. Decentralized Finance (DeFi): Ethereum is widely used for building DeFi applications, including
decentralized exchanges (DEXs), lending platforms, stablecoins, yield farming protocols, and more. DeFi
applications enable peer-to-peer financial services without the need for traditional intermediaries, such as
banks or brokers.
2. Tokenization and Asset Management: Ethereum allows for the creation and management of digital assets
(tokens) on its blockchain. Tokens can represent various assets, including cryptocurrencies, real estate,
securities, and collectibles. Ethereum's ERC-20, ERC-721, and ERC-1155 token standards have become
widely adopted for tokenization and asset management.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

3. Decentralized Autonomous Organizations (DAOs): Ethereum enables the creation of decentralized


autonomous organizations (DAOs), which are organizations governed by smart contracts and decentralized
decision-making processes. DAOs can manage funds, make collective decisions, and execute actions based
on the consensus of their members.
4. Supply Chain and Logistics: Ethereum can be used for supply chain management and logistics applications,
enabling transparent and traceable tracking of products and goods throughout their lifecycle. Smart contracts
on Ethereum can automate supply chain processes, verify product authenticity, and ensure compliance with
regulations.
5. Gaming and Non-Fungible Tokens (NFTs): Ethereum is a popular platform for building blockchain-based
games and non-fungible token (NFT) marketplaces. NFTs are unique digital assets that represent ownership
of digital or physical items, such as art, collectibles, virtual real estate, and in-game items.

Challenges and Future Directions:


1. Scalability: Ethereum faces scalability challenges, particularly with increasing network congestion and high
gas fees during periods of high demand. The transition to Ethereum 2.0, with its proof-of-stake consensus
mechanism and scalability improvements, aims to address these challenges and enhance the platform's
scalability.
2. Security and Privacy: Smart contract vulnerabilities and security risks, such as reentrancy attacks and
coding errors, pose significant challenges to the security and integrity of Ethereum applications. Improving
smart contract security and enhancing privacy features are ongoing priorities for Ethereum developers.
3. Interoperability and Standards: Interoperability between different blockchain networks and standards for
tokenization and smart contracts remain important areas of focus for Ethereum and the broader blockchain
ecosystem. Collaborative efforts to develop interoperable protocols and standards can promote compatibility
and synergy between different blockchain platforms.
4. Regulatory Compliance: Regulatory uncertainty and compliance requirements pose challenges for
Ethereum and blockchain-based applications, particularly in areas such as DeFi, tokenization, and
decentralized governance. Clarifying regulatory frameworks and establishing industry standards can foster
mainstream adoption and institutional participation in the Ethereum ecosystem.

CONSENSUS MECHANISMS

The term 'consensus mechanism' is often used colloquially to refer to 'proof-of-stake', 'proof-of-work' or 'proof-of-
authority' protocols. However, these are just components in consensus mechanisms that protect against Sybil attacks.
Consensus mechanisms are the complete stack of ideas, protocols and incentives that enable a distributed set of nodes
to agree on the state of a blockchain.

WHAT IS CONSENSUS?
By consensus, we mean that a general agreement has been reached. Consider a group of people going to the cinema.
If there is no disagreement on a proposed choice of film, then a consensus is achieved. If there is disagreement, the
group must have the means to decide which film to see. In extreme cases, the group will eventually split.

In regard to the Ethereum blockchain, the process is formalized, and reaching consensus means that at least 66% of
the nodes on the network agree on the global state of the network.

WHAT IS A CONSENSUS MECHANISM?


The term consensus mechanism refers to the entire stack of protocols, incentives and ideas that allow a network of
nodes to agree on the state of a blockchain.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

Ethereum uses a proof-of-stake-based consensus mechanism that derives its crypto-economic security from a set of
rewards and penalties applied to capital locked by stakers. This incentive structure encourages individual stakers to
operate honest validators, punishes those who don't, and creates an extremely high cost to attack the network.

Then, there is a protocol that governs how honest validators are selected to propose or validate blocks, process
transactions and vote for their view of the head of the chain. In the rare situations where multiple blocks are in the
same position near the head of the chain, there is a fork-choice mechanism that selects blocks that make up the
'heaviest' chain, measured by the number of validators that voted for the blocks weighted by their staked ether balance.
Some concepts are important to consensus that are not explicitly defined in code, such as the additional security offered
by potential out-of-band social coordination as a last line of defense against attacks on the network. These components
together form the consensus mechanism.

TYPES OF CONSENSUS MECHANISMS

1. PROOF-OF-WORK (POW)

The Ethereum network began by using a consensus mechanism that involved Proof-of-work (PoW). This allowed
the nodes of the Ethereum network to agree on the state of all information recorded on the Ethereum blockchain and
prevented certain kinds of economic attacks. However, Ethereum switched off proof-of-work in 2022 and started
using proof-of-stake instead.

Proof-of-work has now been deprecated. Ethereum no longer uses proof-of-work as part of its consensus
mechanism. Instead, it uses proof-of-stake.

WHAT IS PROOF-OF-WORK (POW)?


Nakamoto consensus, which utilizes proof-of-work, is the mechanism that once allowed the decentralized Ethereum
network to come to consensus (i.e. all nodes agree) on things like account balances and the order of transactions. This
prevented users from "double spending" their coins and ensured that the Ethereum chain was tremendously difficult
to attack or manipulate. These security properties now come from proof-of-stake instead using the consensus
mechanism known as Gasper.

PROOF-OF-WORK AND MINING


Proof-of-work is the underlying algorithm that sets the difficulty and rules for the work miners do on proof-of-work
blockchains. Mining is the "work" itself. It's the act of adding valid blocks to the chain. This is important because the
chain's length helps the network follow the correct fork of the blockchain. The more "work" done, the longer the chain,
and the higher the block number, the more certain the network can be of the current state of things.

HOW DID ETHEREUM'S PROOF-OF-WORK WORK?


Ethereum transactions are processed into blocks. In the now-deprecated proof-of-work Ethereum, each block
contained:
• block difficulty – for example: 3,324,092,183,262,715
• mixHash – for example: 0x44bca881b07a6a09f83b130798072441705d9a665c5ac8bdf2f39a3cdf3bee29
• nonce – for example: 0xd3ee432b4fb3d26b
This block data was directly related to proof-of-work.

The work in proof-of-work


The proof-of-work protocol, Ethash, required miners to go through an intense race of trial and error to find the nonce
for a block. Only blocks with a valid nonce could be added to the chain.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

When racing to create a block, a miner repeatedly put a dataset, that could only be obtained by downloading and
running the full chain (as a miner does), through a mathematical function. The dataset was used to generate a mixHash
below a target that is dictated by the block difficulty. The best way to do this is through trial and error.

The difficulty determined the target for the hash. The lower the target, the smaller the set of valid hashes. Once
generated, this was incredibly easy for other miners and clients to verify. Even if one transaction were to change, the
hash would be completely different, signalling fraud.

Hashing makes fraud easy to spot. But proof-of-work as a process was also a big deterrent to attacking the chain.

Proof-of-work and security


Miners were incentivized to do this work on the main Ethereum chain. There was little incentive for a subset of miners
to start their own chain—it undermines the system. Blockchains rely on having a single state as a source of truth.

The objective of proof-of-work was to extend the chain. The longest chain was most believable as the valid one
because it had the most computational work done to generate it. Within Ethereum's PoW system, it was nearly
impossible to create new blocks that erase transactions, create fake ones, or maintain a second chain. That's because a
malicious miner would have needed to always solve the block nonce faster than everyone else.

To consistently create malicious yet valid blocks, a malicious miner would have needed over 51% of the network
mining power to beat everyone else. That amount of "work" requires a lot of expensive computing power and the
energy spent might even have outweighed the gains made in an attack.

FINALITY
A transaction has "finality" on Ethereum when it's part of a block that can't change.
Because miners worked in a decentralized way, two valid blocks could be mined at the same time. This creates a
temporary fork. Eventually, one of these chains became the accepted chain after subsequent blocks were mined and
added to it, making it longer.

To complicate things further, transactions rejected on the temporary fork may not have been included in the accepted
chain. This means it could get reversed. So finality refers to the time you should wait before considering a transaction
irreversible. Under the previous proof-of-work Ethereum, the more blocks were mined on top of a specific block N,
the higher confidence that the transactions in N were successful and would not be reverted. Now, with proof-of-stake,
finalization is an explicit, rather than probabilistic, property of a block.

2. PROOF-OF-STAKE (POS)

Proof-of-stake (PoS) underlies Ethereum's consensus mechanism. Ethereum switched on its proof-of-stake
mechanism in 2022 because it is more secure, less energy-intensive, and better for implementing new scaling solutions
compared to the previous proof-of-work architecture.

WHAT IS PROOF-OF-STAKE (POS)?


Proof-of-stake is a way to prove that validators have put something of value into the network that can be destroyed if
they act dishonestly. In Ethereum's proof-of-stake, validators explicitly stake capital in the form of ETH into a smart
contract on Ethereum. The validator is then responsible for checking that new blocks propagated over the network are
valid and occasionally creating and propagating new blocks themselves. If they try to defraud the network (for example
by proposing multiple blocks when they ought to send one or sending conflicting attestations), some or all of their
staked ETH can be destroyed.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

VALIDATORS
To participate as a validator, a user must deposit 32 ETH into the deposit contract and run three separate pieces of
software: an execution client, a consensus client, and a validator client. On depositing their ETH, the user joins an
activation queue that limits the rate of new validators joining the network. Once activated, validators receive new
blocks from peers on the Ethereum network. The transactions delivered in the block are re-executed to check that the
proposed changes to Ethereum's state are valid, and the block signature is checked. The validator then sends a vote
(called an attestation) in favor of that block across the network.

Whereas under proof-of-work, the timing of blocks is determined by the mining difficulty, in proof-of-stake, the tempo
is fixed. Time in proof-of-stake Ethereum is divided into slots (12 seconds) and epochs (32 slots). One validator is
randomly selected to be a block proposer in every slot. This validator is responsible for creating a new block and
sending it out to other nodes on the network. Also in every slot, a committee of validators is randomly chosen, whose
votes are used to determine the validity of the block being proposed. Dividing the validator set up into committees is
important for keeping the network load manageable. Committees divide up the validator set so that every active
validator attests in every epoch, but not in every slot.

FINALITY
A transaction has "finality" in distributed networks when it is part of a block that can't change without a large amount
of ETH getting burned. On proof-of-stake Ethereum, this is managed using "checkpoint" blocks. The first block in
each epoch is a checkpoint. Validators vote for pairs of checkpoints that it considers to be valid. If a pair of checkpoints
attracts votes representing at least two-thirds of the total staked ETH, the checkpoints are upgraded. The more recent
of the two (target) becomes "justified". The earlier of the two is already justified because it was the "target" in the
previous epoch. Now it is upgraded to "finalized".

To revert a finalized block, an attacker would commit to losing at least one-third of the total supply of staked ETH.
Since finality requires a two-thirds majority, an attacker could prevent the network from reaching finality by voting
with one-third of the total stake. There is a mechanism to defend against this: the inactivity leak. This activates
whenever the chain fails to finalize for more than four epochs. The inactivity leak bleeds away the staked ETH from
validators voting against the majority, allowing the majority to regain a two-thirds majority and finalize the chain.

PROOF-OF-STAKE AND SECURITY


The threat of a 51% attack still exists on proof-of-stake as it does on proof-of-work, but it's even riskier for the
attackers. An attacker would need 51% of the staked ETH. They could then use their own attestations to ensure their
preferred fork was the one with the most accumulated attestations. The 'weight' of accumulated attestations is what
consensus clients use to determine the correct chain, so this attacker would be able to make their fork the canonical
one. However, a strength of proof-of-stake over proof-of-work is that the community has flexibility in mounting a
counter-attack. For example, the honest validators could decide to keep building on the minority chain and ignore the
attacker's fork while encouraging apps, exchanges, and pools to do the same. They could also decide to forcibly remove
the attacker from the network and destroy their staked ETH. These are strong economic defenses against a 51% attack.
51% attacks are just one flavor of malicious activity. Bad actors could attempt long-range attacks (although the finality
gadget neutralizes this attack vector), short range 'reorgs' (although proposer boosting and attestation deadlines
mitigate this), bouncing and balancing attacks (also mitigated by proposer boosting, and these attacks have anyway
only been demonstrated under idealized network conditions) or avalanche attacks (neutralized by the fork choice
algorithms rule of only considering the latest message).

Overall, proof-of-stake, as it is implemented on Ethereum, has been demonstrated to be more economically


secure than proof-of-work.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

SMART CONTRACTS

Smart contracts are self-executing contracts with the terms of the agreement directly written into code. They run on a
blockchain network and automatically execute transactions and enforce agreements when predefined conditions are
met. Smart contracts enable trustless and decentralized execution of agreements, eliminating the need for
intermediaries and enhancing security and efficiency in various applications.

Key Features of Smart Contracts:


1. Code-based Contracts: Smart contracts are written in programming languages specifically designed for
blockchain platforms, such as Solidity for Ethereum. The code defines the terms and conditions of the
contract, including the parties involved, conditions triggering contract execution, and actions to be taken
upon fulfillment of these conditions.
2. Decentralized Execution: Smart contracts are deployed on a blockchain network and run on the network's
decentralized nodes. They operate autonomously without the need for intermediaries or centralized control,
ensuring censorship resistance, immutability, and transparency in contract execution.
3. Automated Transactions: Smart contracts enable automated execution of transactions and agreements based
on predefined conditions. When conditions specified in the contract are met, the contract automatically
triggers the associated actions, such as transferring assets, releasing funds, or updating data on the blockchain.
4. Trustless Transactions: Smart contracts eliminate the need for trust between parties, as the execution of the
contract's terms is enforced by the underlying blockchain network. Participants can rely on cryptographic
security and consensus mechanisms of the blockchain to ensure the integrity and fairness of the contract's
execution.
5. Immutable and Tamper-proof: Once deployed on the blockchain, smart contracts are immutable, meaning
their code and execution cannot be altered. This ensures that the terms of the contract remain tamper-proof
and transparent, as the contract's code and execution history are publicly verifiable on the blockchain.
6. Wide Range of Applications: Smart contracts have a wide range of applications beyond simple financial
transactions. They can be used for decentralized finance (DeFi) applications, supply chain management,
voting systems, decentralized autonomous organizations (DAOs), digital identity management, and more.
Smart contracts enable the automation of various business processes and the creation of new decentralized
applications (DApps).

Development and Deployment:


1. Writing Smart Contracts: Developers write smart contracts using specific programming languages
supported by the blockchain platform they are deploying on, such as Solidity for Ethereum. Smart contracts
define the logic and rules governing the agreement and are typically reviewed and tested thoroughly to ensure
correctness and security.
2. Deployment on Blockchain: Once written, smart contracts are deployed to the blockchain network. This
involves submitting the contract code to the network and paying a fee (gas fee in Ethereum) to deploy it.
Once deployed, the smart contract is assigned a unique address on the blockchain, which serves as its
identifier and entry point for interaction.

Interaction and Execution:


1. Participant Interaction: Parties involved in the contract, such as users or other smart contracts, can interact
with it by sending transactions to its address on the blockchain. These interactions can involve executing
functions defined in the smart contract, such as sending tokens, updating data, or triggering specific actions
based on predefined conditions.
2. Blockchain Validation: When a transaction is sent to the smart contract, it is processed by the blockchain
network's nodes through a process called mining or validation, depending on the consensus mechanism. The
nodes execute the code of the smart contract and verify its outcome against the rules defined in the contract.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

3. Result and Confirmation: Once the contract's code is executed and its outcome verified by the network, the
transaction is confirmed and added to a block on the blockchain. The transaction, along with the contract's
execution result, becomes a permanent part of the blockchain's immutable ledger, providing transparency and
auditability of the contract's execution.

Use Cases of Smart Contracts:


1. Decentralized Finance (DeFi): Smart contracts are widely used in DeFi applications, including
decentralized exchanges (DEXs), lending platforms, liquidity pools, and yield farming protocols. DeFi
applications enable peer-to-peer financial services without the need for traditional intermediaries, such as
banks or brokers.
2. Tokenization and Asset Management: Smart contracts facilitate the creation and management of digital
assets (tokens) on the blockchain. Tokens can represent various assets, including cryptocurrencies, real estate,
securities, and collectibles. Smart contracts enable tokenization of assets, issuance of tokens, and
management of token transfers and ownership.
3. Decentralized Autonomous Organizations (DAOs): Smart contracts enable the creation and operation of
decentralized autonomous organizations (DAOs), which are organizations governed by smart contracts and
decentralized decision-making processes. DAOs can manage funds, make collective decisions, and execute
actions based on the consensus of their members.
4. Supply Chain and Logistics: Smart contracts can automate supply chain management and logistics
processes by enabling transparent and traceable tracking of products and goods throughout their lifecycle.
Smart contracts can automate processes such as inventory management, product tracking, and supply chain
financing, enhancing efficiency and transparency in supply chain operations.
5. Digital Identity and Authentication: Smart contracts can be used for digital identity management and
authentication, enabling secure and decentralized identity verification and access control. Smart contracts
can store and manage digital identities, verify credentials, and enable secure access to services and resources
based on predefined criteria.

Challenges and Considerations:


1. Security Vulnerabilities: Smart contracts are susceptible to security vulnerabilities and coding errors, such
as reentrancy attacks, integer overflows, and logic bugs. Developers must follow best practices for smart
contract development, including code audits, formal verification, and testing to mitigate these risks.
2. Scalability: Scalability remains a challenge for smart contract platforms, particularly during periods of high
network congestion and transaction volume. Scalability solutions, such as layer 2 scaling solutions, sharding,
and sidechains, are being explored to improve the throughput and performance of smart contract platforms.
3. Regulatory Compliance: Regulatory uncertainty and compliance requirements pose challenges for smart
contract adoption and deployment, particularly in regulated industries such as finance and healthcare.
Compliance with regulations, such as Know Your Customer (KYC) and Anti-Money Laundering (AML)
requirements, is important for ensuring legal and regulatory compliance when deploying smart contracts in
these industries.

WORKING OF SMART CONTRACTS

The working of smart contracts involves several steps, from creation to execution on a blockchain network.

Smart contracts operate as self-executing agreements deployed on blockchain networks, enabling automated and
trustless execution of transactions and agreements. They follow a predefined lifecycle, from creation and deployment
to interaction, execution, and eventual termination or settlement. Smart contracts leverage the security, transparency,
and immutability of blockchain technology to provide reliable and efficient execution of agreements across various
industries and applications.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

1. Creation of Smart Contracts:


• Programming: Smart contracts are written in specialized programming languages, such as Solidity for
Ethereum. Developers code the logic and rules of the contract, including conditions, actions, and participants'
roles.
• Development Environment: Developers typically use integrated development environments (IDEs) or
online editors tailored for smart contract development to write, compile, and debug their code.
2. Deployment of Smart Contracts:
• Submitting to Blockchain: Once the smart contract code is written and tested, it needs to be deployed to the
blockchain network. This involves submitting the contract code and relevant metadata to the network, along
with a transaction fee.
• Transaction Confirmation: Miners or validators on the blockchain network process the deployment
transaction, verify the contract's validity, and include it in a new block. Once confirmed, the smart contract
is assigned a unique address on the blockchain, which serves as its identifier.
3. Interacting with Smart Contracts:
• Transaction Invocation: Parties involved in the contract, such as users or other smart contracts, interact with
it by sending transactions to its address on the blockchain. These transactions invoke functions or methods
defined in the smart contract code.
• Transaction Parameters: Transactions may include parameters or data payloads that specify inputs for the
smart contract function being called, such as values to transfer, conditions to meet, or data to update.
4. Execution of Smart Contracts:
• Blockchain Processing: When a transaction is sent to the smart contract, it is processed by the blockchain
network's nodes through a process called mining (in Proof of Work) or validation (in Proof of Stake).
• Contract Execution: Nodes execute the code of the smart contract in a deterministic manner, ensuring that
the contract behaves as intended and follows the rules defined in its code.
• Transaction Verification: Nodes verify the outcome of the contract execution against the conditions
specified in the contract's code. If the transaction meets the conditions, the contract's actions are executed.
5. Result and Confirmation:
• Transaction Confirmation: Once the contract's code is executed and its outcome verified by the network,
the transaction is confirmed and added to a block on the blockchain.
• Blockchain Consensus: The transaction confirmation process involves achieving consensus among network
nodes to ensure agreement on the validity of the transaction and the state changes caused by the contract
execution.
• Immutable Ledger: The transaction, along with the contract's execution result, becomes a permanent part
of the blockchain's immutable ledger, providing transparency and auditability of the contract's execution.
6. Handling Events and Errors:
• Event Logging: Smart contracts can emit events during their execution to notify interested parties about
specific occurrences or state changes. These events are logged on the blockchain and can be monitored by
external applications or users.
• Error Handling: Smart contracts may include error handling mechanisms to deal with exceptional
conditions or invalid inputs gracefully. Error handling ensures that contracts behave predictably and do not
get stuck in erroneous states.
7. End of Contract Lifecycle:
• Contract Termination: Smart contracts may have predefined termination conditions or expiration dates.
Once these conditions are met, the contract may self-destruct or enter a dormant state, depending on its
design.
• Refunds and Settlements: Upon termination, smart contracts may release any remaining funds or assets
held in escrow, refund participants, or distribute assets according to predefined rules.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

METAMASK

MetaMask is a cryptocurrency wallet and browser extension that enables users to interact with decentralized
applications (DApps) and blockchain networks directly from their web browsers. It serves as a digital wallet for storing
cryptocurrencies, managing assets, and facilitating transactions on blockchain platforms, primarily Ethereum.

MetaMask provides users with a user-friendly interface accessible via a browser toolbar icon. From there, users can
access their wallet, view transaction history, manage account settings, and interact with DApps seamlessly without the
need for additional software or tools.

Key features of MetaMask include:


1. Wallet Management: MetaMask allows users to securely store various cryptocurrencies, including Ether
(ETH), Ethereum-based tokens, and assets built on other supported blockchain networks.
2. Browser Integration: MetaMask is available as a browser extension compatible with major web browsers
such as Chrome, Firefox, Brave, and Edge. Users can install MetaMask as an extension and access its features
directly within their browser.
3. DApp Interaction: MetaMask enables users to interact with decentralized applications (DApps) built on
blockchain platforms such as Ethereum. Users can access DApps directly from their browser and seamlessly
connect their MetaMask wallet to perform various actions and transactions.
4. Network Integration: MetaMask supports multiple Ethereum networks, including the mainnet (Ethereum's
production network) and various testnets such as Ropsten, Kovan, and Rinkeby. Users can switch between
networks to test DApps or interact with different blockchain environments.
5. Security and Privacy: MetaMask employs robust encryption and security measures to protect users' private
keys and sensitive data stored within the browser extension. It also provides features for securely backing up
and recovering wallet data, controlling privacy settings, and protecting against phishing attacks.

MetaMask Setup

Setting up MetaMask involves several steps, including installation, account creation, and configuration.

Key steps involved:


1. Installation:
• Browser Extension: MetaMask is available as a browser extension for major web browsers such as Chrome,
Firefox, Brave, and Edge. Users can download and install MetaMask from the respective browser's extension
store or from the MetaMask website.
• Add Extension: Once downloaded, users can add the MetaMask extension to their browser by clicking on
the extension icon or following the installation prompts provided by the browser.
2. Account Creation:
• Get Started: After installing MetaMask, users can launch the extension by clicking on the MetaMask icon
in the browser toolbar. The extension will display a welcome screen prompting users to get started.
• Create a New Wallet: Users can choose to create a new wallet by clicking on the "Create a Wallet" or "Get
Started" button. They will be guided through the process of setting up a new wallet, including creating a
strong password and agreeing to the terms of service.
• Backup Seed Phrase: Upon creating a new wallet, MetaMask will generate a unique mnemonic seed phrase
(also known as a recovery phrase) consisting of 12 or 24 words. Users must write down and securely store
this seed phrase as it is required for wallet recovery and backup.
3. Configuration:
• Password: Users can set up a password to secure their MetaMask wallet. This password is required to unlock
the wallet and authorize transactions.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

• Seed Phrase Backup: MetaMask will prompt users to verify their seed phrase by entering it in the correct
order. Users must carefully enter the words to ensure accuracy.
• Network Selection: MetaMask supports multiple Ethereum networks, including the Ethereum Mainnet and
various testnets. Users can select the desired network from the dropdown menu in the MetaMask interface.
4. Additional Settings:
• Privacy Settings: Users can configure privacy settings in MetaMask to control data sharing and permissions
for accessing wallet data and interacting with decentralized applications (DApps).
• Token Management: MetaMask allows users to manage Ethereum-based tokens by adding custom tokens
to their wallets, viewing token balances, and sending or receiving tokens.
• Customization: Users can customize MetaMask settings, such as language preferences, currency display
options, and transaction preferences, to suit their preferences and needs.
5. Backup and Recovery:
• Backup Seed Phrase: MetaMask emphasizes the importance of backing up the mnemonic seed phrase
generated during wallet creation. Users should securely store the seed phrase in multiple locations to ensure
they can recover their wallet in case of loss or device failure.
• Wallet Recovery: In case of wallet loss or device change, users can restore their MetaMask wallet using the
mnemonic seed phrase. They need to install MetaMask on a new device and select the option to restore a
wallet using the seed phrase.

6. Security Measures:
• Security Best Practices: MetaMask encourages users to follow security best practices, such as enabling two-
factor authentication (2FA), using strong and unique passwords, and keeping their devices and browsers up
to date.
• Phishing Protection: MetaMask provides phishing protection features to warn users about suspicious
websites or DApps that may attempt to steal their cryptocurrency or sensitive information.

ETHEREUM ACCOUNTS

Ethereum accounts play a crucial role in the Ethereum blockchain ecosystem, serving as the primary means for users
to interact with the network, store funds, and execute transactions. Ethereum accounts are essential components of the
Ethereum blockchain ecosystem, enabling users to interact with the network, store funds, and execute transactions
securely and autonomously. Understanding the structure and functionality of Ethereum accounts is crucial for
participating in the Ethereum ecosystem and leveraging its capabilities for decentralized finance, decentralized
applications, and other blockchain-based solutions.

1. Types of Ethereum Accounts:


There are two main types of Ethereum accounts:
• Externally Owned Accounts (EOAs): EOAs are controlled by private keys and are owned and managed by
individuals or entities. They are similar to traditional cryptocurrency wallets and can send transactions,
interact with smart contracts, and hold Ether and other Ethereum-based tokens.
• Contract Accounts: Contract accounts are controlled by the code of smart contracts deployed on the
Ethereum blockchain. They do not have associated private keys and are instead managed by the code's logic.
Contract accounts hold and manage funds autonomously according to the rules defined in the smart contract
code.
2. Structure of Ethereum Accounts:
• Address: Each Ethereum account is identified by a unique address, which is a 20-byte hexadecimal string
(40 characters). Addresses are generated from the public key associated with the account using cryptographic

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

algorithms. They serve as the destination for sending Ether and tokens and as identifiers for interacting with
contracts.
• Private Key: For externally owned accounts (EOAs), the private key is used to control and manage the
account. Private keys are randomly generated 256-bit numbers and are mathematically linked to the account's
public key and address. Private keys must be kept secure and should never be shared or exposed.
• Balance: Ethereum accounts maintain a balance, which represents the amount of Ether and tokens held by
the account. The balance is recorded on the Ethereum blockchain and can be queried by anyone using the
account's address.
3. Account Management and Transactions:
• Transactions: Ethereum accounts can send and receive transactions on the Ethereum blockchain.
Transactions involve transferring Ether or tokens between accounts, interacting with smart contracts, or
executing other operations on the Ethereum network.
• Digital Signatures: Transactions sent from EOAs require digital signatures generated using the account's
private key. Digital signatures provide cryptographic proof of ownership and authorization for the transaction.
Contract accounts execute transactions based on the rules defined in the associated smart contract code.
• Nonce: Each Ethereum account has a nonce, which is a unique sequential number assigned to each transaction
sent from the account. The nonce prevents replay attacks and ensures the order and integrity of transactions
from the account.
4. Account Interaction:
• Sending Transactions: Users can send transactions from their Ethereum accounts using wallet software or
browser extensions like MetaMask. Transactions involve specifying the recipient address, amount of Ether
or tokens to send, and optional data payload.
• Interacting with Contracts: Ethereum accounts can interact with smart contracts deployed on the Ethereum
blockchain. Interactions include calling functions defined in the smart contract code, sending data to the
contract, and executing specific actions based on the contract's logic.
5. Security Considerations:
• Private Key Security: Securing the private key is critical for protecting Ethereum accounts from
unauthorized access and theft. Users should store private keys securely, preferably offline, and avoid sharing
them or exposing them to potential risks.
• Phishing and Scams: Users should be cautious of phishing attacks and scams targeting Ethereum accounts.
They should verify the authenticity of websites, applications, and messages before sharing sensitive
information or executing transactions.

RECEIVING ETHER

Receiving Ether (ETH) involves obtaining funds sent to your Ethereum account from another account or address.

Receiving Ether involves generating an Ethereum address, sharing it with the sender, and confirming the receipt of
funds in your Ethereum account after the sender initiates the transaction. Understanding the process of receiving Ether
is essential for effectively managing your Ethereum holdings and participating in cryptocurrency transactions on the
Ethereum network.

Key steps involved:


1. Ethereum Address:
• To receive Ether, you need an Ethereum address. If you don't already have one, you can easily generate a
new Ethereum address using a wallet application or a browser extension like MetaMask. Each Ethereum
address is represented by a unique 20-byte hexadecimal string (40 characters) and serves as the destination
for receiving Ether.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY
CA576 BLOCKCHAIN COMPUTING

UNIT-III

2. Sharing Your Ethereum Address:


• Once you have your Ethereum address, you need to share it with the sender who intends to transfer Ether to
you. You can share your Ethereum address via various methods, including:
• Providing the address as a text string or QR code.
• Sharing a link to your Ethereum address on blockchain explorers or wallet applications.
• Displaying your Ethereum address publicly on websites or social media platforms.
3. Initiating the Transaction:
• The sender initiates the Ether transfer by creating and sending a transaction to your Ethereum address. They
specify your Ethereum address as the recipient of the Ether, along with the amount they wish to send.
4. Transaction Confirmation:
• Once the sender submits the transaction, it is broadcasted to the Ethereum network and included in a block
by miners or validators. The transaction undergoes confirmation through the consensus mechanism of the
Ethereum network.
5. Funds Reflecting in Your Account:
• After the transaction is confirmed and included in a block, the Ether sent by the sender will reflect in your
Ethereum account. You can view the updated balance of your account, which will include the received Ether
amount.
6. Checking Transaction Status:
• You can use blockchain explorers or wallet applications to monitor the status of the transaction. Blockchain
explorers allow you to search for your Ethereum address and view transaction details, including confirmation
status, transaction hash, and block height.
7. Security Considerations:
• Ensure that you share your Ethereum address securely and only with trusted individuals or entities to prevent
unauthorized access to your funds.
• Verify the sender's identity and transaction details before accepting Ether transfers to avoid falling victim to
scams or phishing attacks.

DR. AFREEN KHAN | ASSISTANT PROFESSOR


DEPARTMENT OF COMPUTER APPLICATION | INTEGRAL UNIVERSITY

You might also like