LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - I
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
INDEX:
• Describe the origin of Blockchain.
• Why is Blockchain important to learn.
Origin of Blockchain Technology
• The blockchain technology was described in 1991 by the research scientist
Stuart Haber and W. Scott Stornetta. They wanted to introduce a
computationally practical solution for time-stamping digital documents so
that they could not be backdated or tampered. They develop a system
using the concept of cryptographically secured chain of blocks to store the
time-stamped documents.
• In 1992, Merkle Trees were incorporated into the design, which makes
blockchain more efficient by allowing several documents to be collected
into one block. Merkle Trees are used to create a 'secured chain of blocks.'
It stored a series of data records, and each data records connected to the
one before it. The newest record in this chain contains the history of the
entire chain. However, this technology went unused, and the patent lapsed
in 2004.
Importance of Blockchain
#1: Job prospects in blockchain are growing strongly
Blockchain is already improving the way businesses operate, from banking and
finance, agriculture and supply chain, to government, healthcare and education. As
a growing number of organizations adopt the technology, blockchain is increasingly
becoming a transferable skill.
#2: Being skilled in blockchain positions you at the forefront of change
With skills in blockchain-enabled business, you’ll have the ability to operationalize
blockchain technology, transform stagnant industries and lead improved business
models.
#3: Blockchain technology will revolutionize a range of industries
Blockchain is already improving business operation within a number of sectors,
from banking and finance, agriculture, and supply chain, to government, healthcare
and education. As more organisations adopt the technology, blockchain is
increasingly becoming a transferable skill.
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - II
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
INDEX:
Programming on Solidity
• Introduction to Solidity
• What is Smart Contract
• What is EVM
Introduction to Solidity
• Solidity is an object-oriented programming language for
implementing smart contracts on various blockchain platforms, most
notably, Ethereum. It was developed by Christian Reitwiessner, Alex
Beregszaszi, and several former Ethereum core contributors.
Programs in Solidity run on Ethereum Virtual Machine.
• Solidity was proposed in August 2014 by Gavin Wood; the language
was later developed by the Ethereum project's Solidity team, led by
Christian Reitwiessner.
What is Smart Contract
• Smart contracts are simply programs stored on a blockchain that run
when predetermined conditions are met. They typically are used to
automate the execution of an agreement so that all participants can
be immediately certain of the outcome, without any intermediary’s
involvement or time loss. They can also automate a workflow,
triggering the next action when conditions are met.
What is EVM
• The Ethereum Virtual Machine (EVM) is a complex, dedicated software
virtual stack that executes contract bytecode and is integrated into each
entire Ethereum node. Simply said, EVM is a software framework that
allows developers to construct Ethereum-based decentralized applications
(DApps). All Ethereum accounts and smart contracts are stored on this
virtual computer.
• Contracts are usually authored in high-level languages like Solidity and then
compiled into EVM bytecode. This implies that the machine code is
separated from the host computer's network, disc, and other operations.
Every node in the Ethereum network runs an EVM instance, allowing them
to agree on the same set of instructions to be executed.
Online Solidity IDE
Creating a new Workspace on IDE
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - III
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
INDEX:
• How are you going to store data in Smart Contract.
• Describe Pragma.
• Describe some programming terms.
• Write down Syntax for Solidity Code.
• Write down Data Types used in Solidity.
How are you going to store data in Smart
Contract.
• Any contract data must be assigned to a location: either to storage or
memory. It's costly to modify storage in a smart contract so you need
to consider where your data should live.
• Persistent data is referred to as storage and is represented by state
variables. These values get stored permanently on the blockchain. You
need to declare the type so that the contract can keep track of how
much storage on the blockchain it needs when it compiles.
What is Pragma
• In computer programming, a directive or pragma is a language construct
that specifies how a compiler should process its input. Directives are not
part of the grammar of a programming language, and may vary from
compiler to compiler. They can be processed by a preprocessor to specify
compiler behavior, or function as a form of in-band parameterization.
• In some cases directives specify global behavior, while in other cases they
only affect a local section, such as a block of programming code. In some
cases, such as some C programs, directives are optional compiler hints, and
may be ignored, but normally they are prescriptive, and must be followed.
However, a directive does not perform any action in the language itself, but
rather only a change in the behavior of the compiler.
Some Programming Terms:
• Remix: Remix is a browser based IDE with integrated compiler and solidity run-
time environment without server side components
• Solium: Solium is a linter to identify and fix style and security issues in solidity
• Doxity: Doxity is a tool which is used in solidity as a documentation generator
• Solograph: Solograph is used to visualize solidity control flow and highlight
potential security vulnerabilities
• Solidity Assembly: Solidity defines an assembly language which can be used
without solidity and can be used as inline assembly inside solidity source code
• Gas: Gas is a measurement roughly equivalent to the computational steps
• Block Gas limit: It is used to control the amount of gas consumed during the
transactions
Syntax in Solidity
• Syntax to import the files
import "filename";
import * as symbolName from "filename"; or import
"filename" as symbolName;
import {symbol1 as alias, symbol2} from "filename";
Datatypes in Solidity
• Boolean
Boolean syntax:
bool: true or false
Operators:
Logical:
! (Logical negation)
&& (AND)
|| (OR)
Comparisons:
== (equality)
!= (inequality)
• Integer
Unsigned Integer:
Eg: uint8 | uint16 | uint32 |
unit64 | uint128 | uint256 (uint)
Signed integer: int8 | int16 |
int32 | nit64 | int128 | int256
(uint)
Operators:
Comparisons:
<= (Less than or equal to)
< (Less than)
== (equal to)
!= (Not equal to)
Continued..
Bitwise operators:
• & (AND)
• | (OR)
• ^ (Bitwise Exclusive OR)
• ~ (Bitwise negation)
Arithmetic Operators:
• + (Addition)
• - (Subtraction)
• Unary –
• Unary +
• *(Multiplication)
• % (Division)
• ** (Exponential)
• << (Left shift)
• >> (Right shift)
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - IV
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
Content
• Writing our first Solidity Program by printing "Hello
World!".
Solidity Program to print "Hello World!"
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - V
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
CONTENTS:
• What are the Solidity Language's Primitive Data Type
• Write a program using Solidity Primitive Data Types
Solidity Language's Primitive Data Types.
The following types are value types in Solidity:
• boolean
• integers
• unsigned integers
• addresses
Booleans
Booleans, of course, can hold two values true or false. Solidity supports all your
regular boolean operators, such as !, &&, == etc. They only take up 1 byte of
storage.
bool public a_boolean;
Signed and unsigned integers
Signed integers are declared with the int keyword, unsigned integers with the
uint and both take up 32 bytes by default. If you know your variable will never
hold that many bytes you can always make it smaller by explicitly specifying the
number of bits. For example int128/uint128. You can specify this in steps of 8
starting from 8 up till 256. You can use regular comparison, arithmetic, and bitwise
operators on both int and uint.
Addresses
When it comes to addresses, things start to get a bit more interesting. We
will go into greater detail on addresses in another lesson, but for now, you
should know that there are two types of addresses, Externally Owned
Addresses (EOA) and contract addresses. An EOA is an address to an
Ethereum account, just like an inbox has an email address. You can use this
to send/receive funds. The contract address is the address associated with a
smart contract, and it is used to send/receive money to and from that
contract. In both cases, the address is in the format of a 42 character
hexadecimal address. The address is derived from the first 20 bytes of the
public key controlling the account (if it’s an EOA), or deploying the contract
(if it’s a smart contract). So every address takes up 20 bytes of storage. You
declare an address like this:
address public an_address;
Solidity Program for Primitive Datatype implementation.
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - VI
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
CONTENTS:
• Describe ERC-20 tokens in Solidity.
• Describe methods of ERC-20 tokens.
ERC-20 Tokens in Solidity
An ERC20 token contract keeps track of fungible tokens: any one token
is exactly equal to any other token; no tokens have special rights or
behavior associated with them. This makes ERC20 tokens useful for
things like a medium of exchange currency, voting rights, staking, and
more.
ERC Token standard token is a smart contract token that follows the
Ethereum Request for Comment proposal 20 guidelines.
ERC-20 Token Standard has some mandatory functions to be present in
our programs.
Functions in ERC-20 Token Standard
• function totalSupply() public view returns (uint256);
• function balanceOf(address tokenOwner) public view returns (uint);
• function allowance(address tokenOwner, address spender)
• function transfer(address to, uint tokens) public returns (bool);
• function approve(address spender, uint tokens) public returns (bool);
• function transferFrom(address from, address to, uint tokens) public
returns (bool);
Events which emit to the External
Application
• event Approval(address indexed tokenOwner, address indexed
spender, uint tokens);
• event Transfer(address indexed from, address indexed to, uint
tokens);
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - VII
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
CONTENTS:
• What is Web3 in Blockchain?
• Write down about top 10 tokens in Web3 that are
available in the market.
• Mention the difference between Web2 and Web3 in
Ethereum platform.
What is Web3 in Blockchain?
Web3 (also known as Web 3.0)is an idea for a new iteration of the
World Wide Web which incorporates concepts such as decentralization,
blockchain technologies, and token-based economics. Some
technologists and journalists have contrasted it with Web 2.0, wherein
they say data and content are centralized in a small group of companies
sometimes referred to as "Big Tech". The term "Web3" was coined in
2014 by Ethereum co-founder Gavin Wood, and the idea gained
interest in 2021 from cryptocurrency enthusiasts, large technology
companies, and venture capital firms.
Top 10 Web3 tokens in the market
• Polkadot (DOT)
• Chainlink (LINK)
• Filecoin (FIL)
• Theta Network (THETA)
• BitTorrent- New (BTT)
• The Graph (GRT)
• Helium (HNT)
• Basic Attention Token (BAT)
• Stacks (STX)
• Loopring (LRC)
Mention the difference between Web2 and
Web3 in Ethereum platform.
Web2
• Twitter can censor any account
or tweet
• Payment service may decide to
not allow payments for certain
types of work
• Servers for gig-economy apps
could go down and affect worker
income
Web3
• Web3 tweets would be
uncensorable because control is
decentralized
• Web3 payment apps require no
personal data and can't prevent
payments
• Web3 servers can't go down – they
use Ethereum, a decentralized
network of 1000s of computers as
their backend
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - VIII
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
INDEX:
• Describe SHA-256 Hash Function.
• Implement SHA-256 Hash Function in JavaScript.
• Describe Hash function.
• Implement Hash Function in JavaScript.
Describe SHA-256 Hash Function.
SHA-256 stands for Secure Hash Algorithm 256-bit and it’s used for
cryptographic security.
Cryptographic hash algorithms produce irreversible and unique hashes. The larger the
number of possible hashes, the smaller the chance that two values will create the same
hash.
The SHA-256 algorithm is one flavor of SHA-2 (Secure Hash Algorithm 2), which was
created by the National Security Agency in 2001 as a successor to SHA-1. SHA-256 is a
patented cryptographic hash function that outputs a value that is 256 bits long.
SHA-256 is used in some of the most popular authentication and encryption protocols,
including SSL, TLS, IPsec, SSH, and PGP. In Unix and Linux, SHA-256 is used for secure
password hashing. Cryptocurrencies such as Bitcoin use SHA-256 for verifying
transactions.
Implement SHA-256 hash function in
JavaScript.
Code:
//Converts to 32bit integer
function stringToHashConversion(string) {
var hashVal = 0;
if (string.length == 0) return hashVal;
for (i = 0; i < string.length; i++) {
char = string.charCodeAt(i);
hashVal = ((hashVal << 5) - hashVal) + char;
hashVal = hashVal & hashVal;
}
return hashVal;
}
var input_str = "I am converting string to hash.";
console.log("Input String: "+input_str);
console.log("Hash Value: " + stringToHashConversion(input_str));
Output:
"Input String: I am converting string to hash."
"Hash Value: 625005622"
Describe Hash Function.
A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output is always
of fixed length.
Hash functions are extremely useful and appear in almost all information security applications.
The typical features of hash functions are −
• Fixed Length Output (Hash Value)
• Hash function coverts data of arbitrary length to a fixed length. This
process is often referred to as hashing the data.
• In general, the hash is much smaller than the input data, hence hash
functions are sometimes called compression functions.
• Since a hash is a smaller representation of a larger data, it is also
referred to as a digest.
• Hash function with n bit output is referred to as an n-bit hash
function. Popular hash functions generate values between 160 and
512 bits.
Efficiency of Operation:
• Generally for any hash function h with input x, computation of h(x)
is a fast operation.
• Computationally hash functions are much faster than a symmetric
encryption.
Implement a Hash Function in Javascript.
Code:
getHash() {
return SHA256(this.prevHash + this.timestamp + JSON.stringify(this.data));
}
mine(difficulty) {
// Basically, it loops until our hash starts with
// the string 0...000 with length of <difficulty>.
while (!this.hash.startsWith(Array(difficulty + 1).join("0")))
{
// We increases our nonce so that we can get a whole different hash.
this.nonce++;
// Update our new hash with the new nonce value.
this.hash = this.getHash();
}
}
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - IX
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
INDEX:
• Describe NFT.
• Mention top 5 Web3 applications available in the market and
show their implementation.
Describe NFT.
Non-fungible tokens (NFTs) are cryptographic assets on a blockchain with
unique identification codes and metadata that distinguish them from each
other. Unlike cryptocurrencies, they cannot be traded or exchanged at
equivalency. This differs from fungible tokens like cryptocurrencies, which
are identical to each other and, therefore, can serve as a medium for
commercial transactions.
NFTs (non-fungible tokens) are unique cryptographic tokens that exist on a
blockchain and cannot be replicated. NFTs can represent real-world items
like artwork and real estate.
"Tokenizing" these real-world tangible assets makes buying, selling, and
trading them more efficient while reducing the probability of fraud.
NFTs can also function to represent individuals' identities,
property rights, and more. Collectors have sought NFTs as their value
initially soared, but has since moderated..
Mention top 5 Web3 applications available in
the market and show their implementation.
1) Telegram:
Telegram is one of the most popular messaging services in the world. But it’s still less known than the giants in the industry,
such as WhatsApp or Facebook Messenger. Telegram offers a number of privacy features above and beyond the encryption
that makes it attractive to users. To help protect the privacy of messages sent, the application has an optional “secret chats”
feature.
While using this feature, messages can’t be forwarded, nor can you screenshot them. Secret messages can even self-
destruct. Furthermore, a message that’s been deleted is not only deleted locally but is also deleted for everyone on the
service. The founders have stated that protecting their users’ personal data from third parties such as marketers and
advertisers is a priority for them.
2) Discord:
Discord started largely as a chat app for gamers to allow them to communicate using voice and text chat through private
servers. The software also has screen-sharing capabilities for sharing gameplay or other activities. It has now grown to be
popular outside of the gaming community, with many people choosing to use it to host their own private chat rooms. Any user
who wants to can create their own Discord server. This is a special section of Discord that they have control over. They can
create several channels within the server and invite people to participate in
those channels. As a tool for gamers, the software will tell you which of your friends are online and which games they are
playing. Because it’s meant for gamers, the desktop version of the app is also able to place an overlay over the screen so
you can still interact with the application while using another piece of software in full-screen mode.
3) Storj:
Storj is a cloud storage, which uses a form of technology similar to Blockchain and encrypts data before uploading.
What is special about Storj is that it provides top-tier privacy and security. Storj split the information into 80 pieces
then distribute them to nodes all over the globe. Users have a unique encryption key to access their data, and this
key cannot be recovered once lost. This application also has its own token.
4) Brave Browser:
Brave is a free and open-source web browser developed by Brave Software, Inc. based on the Chromium web
browser. Brave is a privacy-focused browser, which automatically blocks online advertisements and website
trackers in its default settings. It also provides users the choice to turn on optional ads that pay users for their
attention in the form of Basic Attention Tokens (BAT) cryptocurrency. Users can then send contributions to websites
and content creators, which support BAT in the form of tips along with the ability to keep the cryptocurrency they
earned.
5) Facebook (Meta):
Facebook recently announced it would change the name to Meta. This is Zuckerberg’s further step to realizing the
Metaverse. The Metaverse is essentially a virtual reality that mirrors our real world. People can have an identity
within the Metaverse through avatars. The Metaverse is not exactly an application but acts complementary to Web
3.0. Web 3.0 encourages decentralization, and Metaverse allows avatars to move, trade and socialize freely
without restrictions. To summarize, the Metaverse can be the place for work, entertainment, trading, etc. However,
all of these are still being developed. The Metaverse needs many different technologies like connectivity, cloud
services, interfaces to enable the entire ecosystem.
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - X
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
INDEX:
• Describe Web3 wallet.
• Mention implementation of steps of Web3 wallet in
cryptocurrency.
Describe Web3 wallet.
Web3 wallets are essentially digital wallets. As such, they have the
ability to store digital assets. This includes everything from fungible to
non-fungible (NFTs) tokens. A Web3 wallet also opens the door to the
crypto realm, allowing you to interact with dApps on various
blockchains. In turn, wallets help you access an extensive ecosystem
of dApps. Crypto wallets often have a non-custodial characteristic,
which means that you, as a wallet owner, can store digital assets
without the need for an intermediary or middleman. This means that
you as a user remain in complete control of all your assets as no one
else has access to your tokens. However, with exclusive access, all
the responsibility lies with you, meaning that it is essential to keep
private keys to yourself.
Mention implementation steps of Web3
wallet of in cryptocurrency.
We can implement a Web3 wallet using React.Js in the following steps:
Step 1: Creation of a blockchain wallet.
Step 2: The developer need to copy the compiled smart contract that he/she built and
deployed from the truffle project to the ganache Blockchain. One can find the compiled
contract under the build directory of his/her truffle project.
Step 3: Copy the NiceToken.json to the root of the React.Js project. In order to
communicate with the blockchain network, Web3 is used. Web3 can be installed using npm.
Once this is done, the user can communicate with the local Ganache Blockchain network
using Web3.
Step 4: Fetching Data from the Blockchain Network.
Step 5: Transferring Crypto Tokens to another Account Address. For this, one can create a
simple form that lists all the account addresses in a drop-down list, displays the current
account balance, and provides a way to send tokens to another account address using the
two text boxes.
LAKSHMI NARAIN COLLEGE OF
TECHNOLOGY
Fundamentals of Blockchain
Case Study - XI
Submitted to: Prof. Tanushree Dholpuriya
Submitted by: GHANASHVI PARIHAR
Enrollment: 0103IS201019
AIM:
• In this experiment, the user will learn about mining in blockchain i.e. how a
transaction is validated and added into a blockchain.
• We will learn how the process of hashing helps in validation of a block.
• We will also get to know which miner is rewarded when a block is validated and
added to the blockchain.
What is Mining in Blockchain?
In terms of the block chain domain, mining is the procedure of
appending transactions to an enormous distributed ledger of extant
transactions. This concept is well suited for the bitcoin approach but
the diverse technologies that uses the block chain approach can also
perform the approach of mining as well. It allows the creation of a hash
for a block of transactions that cannot be changed easily protecting the
integrity approach of the block chain. The concept of mining goes really
well with the other two approaches that are open ledger and
distributed ledger.
Basic Algorithms Used:
SHA-256 or Secure Hash Algorithm-256 bit is a type of hash function which is
commonly used in Blockchain. SHA-256 changes an input from the user to a
string which is a mixture of numbers and letter which is created through a
cryptographically secure hashing function which is almost 0% similar to the
input. SHA-256 is the strongest hash function available in the current
scenario and it is a successor of SHA-1.
Example:- SHA-256 hash of abc will be 'ba7816bf8f01cfea414140de-
5dae2223b00361a396177a9cb410ff61f20015ad'
ECDSA stands for Elliptic Curve Digital Signature Algorithm. ECDSA consists of
three parts.
●Private Key
●Public Key
●Signature
Procedure:
Steps of simulator :
1. Start with the task regarding concept of mining.(If previously known, otherwise2. Match the following with
the correct answer.
3. Select the first block on left side(Step number).
4. Now, select the block in right in such a way that it is the correct position on left.
5. Do the same procedure for the rest of the steps.
6. Now, after you've done matching click on "VALIDATE" button.
7. If all the answers are correct, then a popup will appear saying "Valid!".
8. If popup shows "Not Valid!" then reset the test by clicking on "RESET" button to restart the test.
9. Now click on initiate mining process to go to the next part.
10. Enter the Name and Amount (Cryptocurrency) of the sender as well as the recipient in the placeholder.
11. Click on the 'Add to block' button to complete the details of a particular user. As soon as the button is
clicked, the details will get added to the block.
12. The illustration will take place according to the inputs given by the user.
13. Complete the same process for the next user.
14. Click on the start mining process button, to start the mining process.
15. Click on the reset button to reset all the details that were entered by the user.
16. The instruction pane will also be there to make the user understand about the basic process that is
happening in the simulator.
skip)
Blockchain Experiments 1-11.pptx
Blockchain Experiments 1-11.pptx
Blockchain Experiments 1-11.pptx

Blockchain Experiments 1-11.pptx

  • 1.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - I Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 2.
    INDEX: • Describe theorigin of Blockchain. • Why is Blockchain important to learn.
  • 3.
    Origin of BlockchainTechnology • The blockchain technology was described in 1991 by the research scientist Stuart Haber and W. Scott Stornetta. They wanted to introduce a computationally practical solution for time-stamping digital documents so that they could not be backdated or tampered. They develop a system using the concept of cryptographically secured chain of blocks to store the time-stamped documents. • In 1992, Merkle Trees were incorporated into the design, which makes blockchain more efficient by allowing several documents to be collected into one block. Merkle Trees are used to create a 'secured chain of blocks.' It stored a series of data records, and each data records connected to the one before it. The newest record in this chain contains the history of the entire chain. However, this technology went unused, and the patent lapsed in 2004.
  • 4.
    Importance of Blockchain #1:Job prospects in blockchain are growing strongly Blockchain is already improving the way businesses operate, from banking and finance, agriculture and supply chain, to government, healthcare and education. As a growing number of organizations adopt the technology, blockchain is increasingly becoming a transferable skill. #2: Being skilled in blockchain positions you at the forefront of change With skills in blockchain-enabled business, you’ll have the ability to operationalize blockchain technology, transform stagnant industries and lead improved business models. #3: Blockchain technology will revolutionize a range of industries Blockchain is already improving business operation within a number of sectors, from banking and finance, agriculture, and supply chain, to government, healthcare and education. As more organisations adopt the technology, blockchain is increasingly becoming a transferable skill.
  • 5.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - II Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 6.
    INDEX: Programming on Solidity •Introduction to Solidity • What is Smart Contract • What is EVM
  • 7.
    Introduction to Solidity •Solidity is an object-oriented programming language for implementing smart contracts on various blockchain platforms, most notably, Ethereum. It was developed by Christian Reitwiessner, Alex Beregszaszi, and several former Ethereum core contributors. Programs in Solidity run on Ethereum Virtual Machine. • Solidity was proposed in August 2014 by Gavin Wood; the language was later developed by the Ethereum project's Solidity team, led by Christian Reitwiessner.
  • 8.
    What is SmartContract • Smart contracts are simply programs stored on a blockchain that run when predetermined conditions are met. They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any intermediary’s involvement or time loss. They can also automate a workflow, triggering the next action when conditions are met.
  • 9.
    What is EVM •The Ethereum Virtual Machine (EVM) is a complex, dedicated software virtual stack that executes contract bytecode and is integrated into each entire Ethereum node. Simply said, EVM is a software framework that allows developers to construct Ethereum-based decentralized applications (DApps). All Ethereum accounts and smart contracts are stored on this virtual computer. • Contracts are usually authored in high-level languages like Solidity and then compiled into EVM bytecode. This implies that the machine code is separated from the host computer's network, disc, and other operations. Every node in the Ethereum network runs an EVM instance, allowing them to agree on the same set of instructions to be executed.
  • 10.
  • 11.
    Creating a newWorkspace on IDE
  • 12.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - III Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 13.
    INDEX: • How areyou going to store data in Smart Contract. • Describe Pragma. • Describe some programming terms. • Write down Syntax for Solidity Code. • Write down Data Types used in Solidity.
  • 14.
    How are yougoing to store data in Smart Contract. • Any contract data must be assigned to a location: either to storage or memory. It's costly to modify storage in a smart contract so you need to consider where your data should live. • Persistent data is referred to as storage and is represented by state variables. These values get stored permanently on the blockchain. You need to declare the type so that the contract can keep track of how much storage on the blockchain it needs when it compiles.
  • 15.
    What is Pragma •In computer programming, a directive or pragma is a language construct that specifies how a compiler should process its input. Directives are not part of the grammar of a programming language, and may vary from compiler to compiler. They can be processed by a preprocessor to specify compiler behavior, or function as a form of in-band parameterization. • In some cases directives specify global behavior, while in other cases they only affect a local section, such as a block of programming code. In some cases, such as some C programs, directives are optional compiler hints, and may be ignored, but normally they are prescriptive, and must be followed. However, a directive does not perform any action in the language itself, but rather only a change in the behavior of the compiler.
  • 16.
    Some Programming Terms: •Remix: Remix is a browser based IDE with integrated compiler and solidity run- time environment without server side components • Solium: Solium is a linter to identify and fix style and security issues in solidity • Doxity: Doxity is a tool which is used in solidity as a documentation generator • Solograph: Solograph is used to visualize solidity control flow and highlight potential security vulnerabilities • Solidity Assembly: Solidity defines an assembly language which can be used without solidity and can be used as inline assembly inside solidity source code • Gas: Gas is a measurement roughly equivalent to the computational steps • Block Gas limit: It is used to control the amount of gas consumed during the transactions
  • 17.
    Syntax in Solidity •Syntax to import the files import "filename"; import * as symbolName from "filename"; or import "filename" as symbolName; import {symbol1 as alias, symbol2} from "filename";
  • 18.
    Datatypes in Solidity •Boolean Boolean syntax: bool: true or false Operators: Logical: ! (Logical negation) && (AND) || (OR) Comparisons: == (equality) != (inequality) • Integer Unsigned Integer: Eg: uint8 | uint16 | uint32 | unit64 | uint128 | uint256 (uint) Signed integer: int8 | int16 | int32 | nit64 | int128 | int256 (uint) Operators: Comparisons: <= (Less than or equal to) < (Less than) == (equal to) != (Not equal to)
  • 19.
    Continued.. Bitwise operators: • &(AND) • | (OR) • ^ (Bitwise Exclusive OR) • ~ (Bitwise negation) Arithmetic Operators: • + (Addition) • - (Subtraction) • Unary – • Unary + • *(Multiplication) • % (Division) • ** (Exponential) • << (Left shift) • >> (Right shift)
  • 20.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - IV Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 21.
    Content • Writing ourfirst Solidity Program by printing "Hello World!".
  • 22.
    Solidity Program toprint "Hello World!"
  • 23.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - V Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 24.
    CONTENTS: • What arethe Solidity Language's Primitive Data Type • Write a program using Solidity Primitive Data Types
  • 25.
    Solidity Language's PrimitiveData Types. The following types are value types in Solidity: • boolean • integers • unsigned integers • addresses
  • 26.
    Booleans Booleans, of course,can hold two values true or false. Solidity supports all your regular boolean operators, such as !, &&, == etc. They only take up 1 byte of storage. bool public a_boolean; Signed and unsigned integers Signed integers are declared with the int keyword, unsigned integers with the uint and both take up 32 bytes by default. If you know your variable will never hold that many bytes you can always make it smaller by explicitly specifying the number of bits. For example int128/uint128. You can specify this in steps of 8 starting from 8 up till 256. You can use regular comparison, arithmetic, and bitwise operators on both int and uint.
  • 27.
    Addresses When it comesto addresses, things start to get a bit more interesting. We will go into greater detail on addresses in another lesson, but for now, you should know that there are two types of addresses, Externally Owned Addresses (EOA) and contract addresses. An EOA is an address to an Ethereum account, just like an inbox has an email address. You can use this to send/receive funds. The contract address is the address associated with a smart contract, and it is used to send/receive money to and from that contract. In both cases, the address is in the format of a 42 character hexadecimal address. The address is derived from the first 20 bytes of the public key controlling the account (if it’s an EOA), or deploying the contract (if it’s a smart contract). So every address takes up 20 bytes of storage. You declare an address like this: address public an_address;
  • 28.
    Solidity Program forPrimitive Datatype implementation.
  • 29.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - VI Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 30.
    CONTENTS: • Describe ERC-20tokens in Solidity. • Describe methods of ERC-20 tokens.
  • 31.
    ERC-20 Tokens inSolidity An ERC20 token contract keeps track of fungible tokens: any one token is exactly equal to any other token; no tokens have special rights or behavior associated with them. This makes ERC20 tokens useful for things like a medium of exchange currency, voting rights, staking, and more. ERC Token standard token is a smart contract token that follows the Ethereum Request for Comment proposal 20 guidelines. ERC-20 Token Standard has some mandatory functions to be present in our programs.
  • 32.
    Functions in ERC-20Token Standard • function totalSupply() public view returns (uint256); • function balanceOf(address tokenOwner) public view returns (uint); • function allowance(address tokenOwner, address spender) • function transfer(address to, uint tokens) public returns (bool); • function approve(address spender, uint tokens) public returns (bool); • function transferFrom(address from, address to, uint tokens) public returns (bool);
  • 33.
    Events which emitto the External Application • event Approval(address indexed tokenOwner, address indexed spender, uint tokens); • event Transfer(address indexed from, address indexed to, uint tokens);
  • 34.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - VII Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 35.
    CONTENTS: • What isWeb3 in Blockchain? • Write down about top 10 tokens in Web3 that are available in the market. • Mention the difference between Web2 and Web3 in Ethereum platform.
  • 36.
    What is Web3in Blockchain? Web3 (also known as Web 3.0)is an idea for a new iteration of the World Wide Web which incorporates concepts such as decentralization, blockchain technologies, and token-based economics. Some technologists and journalists have contrasted it with Web 2.0, wherein they say data and content are centralized in a small group of companies sometimes referred to as "Big Tech". The term "Web3" was coined in 2014 by Ethereum co-founder Gavin Wood, and the idea gained interest in 2021 from cryptocurrency enthusiasts, large technology companies, and venture capital firms.
  • 37.
    Top 10 Web3tokens in the market • Polkadot (DOT) • Chainlink (LINK) • Filecoin (FIL) • Theta Network (THETA) • BitTorrent- New (BTT) • The Graph (GRT) • Helium (HNT) • Basic Attention Token (BAT) • Stacks (STX) • Loopring (LRC)
  • 38.
    Mention the differencebetween Web2 and Web3 in Ethereum platform. Web2 • Twitter can censor any account or tweet • Payment service may decide to not allow payments for certain types of work • Servers for gig-economy apps could go down and affect worker income Web3 • Web3 tweets would be uncensorable because control is decentralized • Web3 payment apps require no personal data and can't prevent payments • Web3 servers can't go down – they use Ethereum, a decentralized network of 1000s of computers as their backend
  • 39.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - VIII Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 40.
    INDEX: • Describe SHA-256Hash Function. • Implement SHA-256 Hash Function in JavaScript. • Describe Hash function. • Implement Hash Function in JavaScript.
  • 41.
    Describe SHA-256 HashFunction. SHA-256 stands for Secure Hash Algorithm 256-bit and it’s used for cryptographic security. Cryptographic hash algorithms produce irreversible and unique hashes. The larger the number of possible hashes, the smaller the chance that two values will create the same hash. The SHA-256 algorithm is one flavor of SHA-2 (Secure Hash Algorithm 2), which was created by the National Security Agency in 2001 as a successor to SHA-1. SHA-256 is a patented cryptographic hash function that outputs a value that is 256 bits long. SHA-256 is used in some of the most popular authentication and encryption protocols, including SSL, TLS, IPsec, SSH, and PGP. In Unix and Linux, SHA-256 is used for secure password hashing. Cryptocurrencies such as Bitcoin use SHA-256 for verifying transactions.
  • 42.
    Implement SHA-256 hashfunction in JavaScript. Code: //Converts to 32bit integer function stringToHashConversion(string) { var hashVal = 0; if (string.length == 0) return hashVal; for (i = 0; i < string.length; i++) { char = string.charCodeAt(i); hashVal = ((hashVal << 5) - hashVal) + char; hashVal = hashVal & hashVal; } return hashVal; } var input_str = "I am converting string to hash."; console.log("Input String: "+input_str); console.log("Hash Value: " + stringToHashConversion(input_str)); Output: "Input String: I am converting string to hash." "Hash Value: 625005622"
  • 43.
    Describe Hash Function. Ahash function is a mathematical function that converts a numerical input value into another compressed numerical value. The input to the hash function is of arbitrary length but output is always of fixed length. Hash functions are extremely useful and appear in almost all information security applications. The typical features of hash functions are − • Fixed Length Output (Hash Value) • Hash function coverts data of arbitrary length to a fixed length. This process is often referred to as hashing the data. • In general, the hash is much smaller than the input data, hence hash functions are sometimes called compression functions. • Since a hash is a smaller representation of a larger data, it is also referred to as a digest. • Hash function with n bit output is referred to as an n-bit hash function. Popular hash functions generate values between 160 and 512 bits. Efficiency of Operation: • Generally for any hash function h with input x, computation of h(x) is a fast operation. • Computationally hash functions are much faster than a symmetric encryption.
  • 44.
    Implement a HashFunction in Javascript. Code: getHash() { return SHA256(this.prevHash + this.timestamp + JSON.stringify(this.data)); } mine(difficulty) { // Basically, it loops until our hash starts with // the string 0...000 with length of <difficulty>. while (!this.hash.startsWith(Array(difficulty + 1).join("0"))) { // We increases our nonce so that we can get a whole different hash. this.nonce++; // Update our new hash with the new nonce value. this.hash = this.getHash(); } }
  • 45.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - IX Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 46.
    INDEX: • Describe NFT. •Mention top 5 Web3 applications available in the market and show their implementation.
  • 47.
    Describe NFT. Non-fungible tokens(NFTs) are cryptographic assets on a blockchain with unique identification codes and metadata that distinguish them from each other. Unlike cryptocurrencies, they cannot be traded or exchanged at equivalency. This differs from fungible tokens like cryptocurrencies, which are identical to each other and, therefore, can serve as a medium for commercial transactions. NFTs (non-fungible tokens) are unique cryptographic tokens that exist on a blockchain and cannot be replicated. NFTs can represent real-world items like artwork and real estate. "Tokenizing" these real-world tangible assets makes buying, selling, and trading them more efficient while reducing the probability of fraud. NFTs can also function to represent individuals' identities, property rights, and more. Collectors have sought NFTs as their value initially soared, but has since moderated..
  • 48.
    Mention top 5Web3 applications available in the market and show their implementation. 1) Telegram: Telegram is one of the most popular messaging services in the world. But it’s still less known than the giants in the industry, such as WhatsApp or Facebook Messenger. Telegram offers a number of privacy features above and beyond the encryption that makes it attractive to users. To help protect the privacy of messages sent, the application has an optional “secret chats” feature. While using this feature, messages can’t be forwarded, nor can you screenshot them. Secret messages can even self- destruct. Furthermore, a message that’s been deleted is not only deleted locally but is also deleted for everyone on the service. The founders have stated that protecting their users’ personal data from third parties such as marketers and advertisers is a priority for them. 2) Discord: Discord started largely as a chat app for gamers to allow them to communicate using voice and text chat through private servers. The software also has screen-sharing capabilities for sharing gameplay or other activities. It has now grown to be popular outside of the gaming community, with many people choosing to use it to host their own private chat rooms. Any user who wants to can create their own Discord server. This is a special section of Discord that they have control over. They can create several channels within the server and invite people to participate in those channels. As a tool for gamers, the software will tell you which of your friends are online and which games they are playing. Because it’s meant for gamers, the desktop version of the app is also able to place an overlay over the screen so you can still interact with the application while using another piece of software in full-screen mode.
  • 49.
    3) Storj: Storj isa cloud storage, which uses a form of technology similar to Blockchain and encrypts data before uploading. What is special about Storj is that it provides top-tier privacy and security. Storj split the information into 80 pieces then distribute them to nodes all over the globe. Users have a unique encryption key to access their data, and this key cannot be recovered once lost. This application also has its own token. 4) Brave Browser: Brave is a free and open-source web browser developed by Brave Software, Inc. based on the Chromium web browser. Brave is a privacy-focused browser, which automatically blocks online advertisements and website trackers in its default settings. It also provides users the choice to turn on optional ads that pay users for their attention in the form of Basic Attention Tokens (BAT) cryptocurrency. Users can then send contributions to websites and content creators, which support BAT in the form of tips along with the ability to keep the cryptocurrency they earned. 5) Facebook (Meta): Facebook recently announced it would change the name to Meta. This is Zuckerberg’s further step to realizing the Metaverse. The Metaverse is essentially a virtual reality that mirrors our real world. People can have an identity within the Metaverse through avatars. The Metaverse is not exactly an application but acts complementary to Web 3.0. Web 3.0 encourages decentralization, and Metaverse allows avatars to move, trade and socialize freely without restrictions. To summarize, the Metaverse can be the place for work, entertainment, trading, etc. However, all of these are still being developed. The Metaverse needs many different technologies like connectivity, cloud services, interfaces to enable the entire ecosystem.
  • 50.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - X Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 51.
    INDEX: • Describe Web3wallet. • Mention implementation of steps of Web3 wallet in cryptocurrency.
  • 52.
    Describe Web3 wallet. Web3wallets are essentially digital wallets. As such, they have the ability to store digital assets. This includes everything from fungible to non-fungible (NFTs) tokens. A Web3 wallet also opens the door to the crypto realm, allowing you to interact with dApps on various blockchains. In turn, wallets help you access an extensive ecosystem of dApps. Crypto wallets often have a non-custodial characteristic, which means that you, as a wallet owner, can store digital assets without the need for an intermediary or middleman. This means that you as a user remain in complete control of all your assets as no one else has access to your tokens. However, with exclusive access, all the responsibility lies with you, meaning that it is essential to keep private keys to yourself.
  • 53.
    Mention implementation stepsof Web3 wallet of in cryptocurrency. We can implement a Web3 wallet using React.Js in the following steps: Step 1: Creation of a blockchain wallet. Step 2: The developer need to copy the compiled smart contract that he/she built and deployed from the truffle project to the ganache Blockchain. One can find the compiled contract under the build directory of his/her truffle project. Step 3: Copy the NiceToken.json to the root of the React.Js project. In order to communicate with the blockchain network, Web3 is used. Web3 can be installed using npm. Once this is done, the user can communicate with the local Ganache Blockchain network using Web3. Step 4: Fetching Data from the Blockchain Network. Step 5: Transferring Crypto Tokens to another Account Address. For this, one can create a simple form that lists all the account addresses in a drop-down list, displays the current account balance, and provides a way to send tokens to another account address using the two text boxes.
  • 54.
    LAKSHMI NARAIN COLLEGEOF TECHNOLOGY Fundamentals of Blockchain Case Study - XI Submitted to: Prof. Tanushree Dholpuriya Submitted by: GHANASHVI PARIHAR Enrollment: 0103IS201019
  • 55.
    AIM: • In thisexperiment, the user will learn about mining in blockchain i.e. how a transaction is validated and added into a blockchain. • We will learn how the process of hashing helps in validation of a block. • We will also get to know which miner is rewarded when a block is validated and added to the blockchain.
  • 56.
    What is Miningin Blockchain? In terms of the block chain domain, mining is the procedure of appending transactions to an enormous distributed ledger of extant transactions. This concept is well suited for the bitcoin approach but the diverse technologies that uses the block chain approach can also perform the approach of mining as well. It allows the creation of a hash for a block of transactions that cannot be changed easily protecting the integrity approach of the block chain. The concept of mining goes really well with the other two approaches that are open ledger and distributed ledger.
  • 57.
    Basic Algorithms Used: SHA-256or Secure Hash Algorithm-256 bit is a type of hash function which is commonly used in Blockchain. SHA-256 changes an input from the user to a string which is a mixture of numbers and letter which is created through a cryptographically secure hashing function which is almost 0% similar to the input. SHA-256 is the strongest hash function available in the current scenario and it is a successor of SHA-1. Example:- SHA-256 hash of abc will be 'ba7816bf8f01cfea414140de- 5dae2223b00361a396177a9cb410ff61f20015ad' ECDSA stands for Elliptic Curve Digital Signature Algorithm. ECDSA consists of three parts. ●Private Key ●Public Key ●Signature
  • 58.
    Procedure: Steps of simulator: 1. Start with the task regarding concept of mining.(If previously known, otherwise2. Match the following with the correct answer. 3. Select the first block on left side(Step number). 4. Now, select the block in right in such a way that it is the correct position on left. 5. Do the same procedure for the rest of the steps. 6. Now, after you've done matching click on "VALIDATE" button. 7. If all the answers are correct, then a popup will appear saying "Valid!". 8. If popup shows "Not Valid!" then reset the test by clicking on "RESET" button to restart the test. 9. Now click on initiate mining process to go to the next part. 10. Enter the Name and Amount (Cryptocurrency) of the sender as well as the recipient in the placeholder. 11. Click on the 'Add to block' button to complete the details of a particular user. As soon as the button is clicked, the details will get added to the block. 12. The illustration will take place according to the inputs given by the user. 13. Complete the same process for the next user. 14. Click on the start mining process button, to start the mining process. 15. Click on the reset button to reset all the details that were entered by the user. 16. The instruction pane will also be there to make the user understand about the basic process that is happening in the simulator. skip)