Lab Manual Blockchain Lab

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 36

Institute’s Vision

To be an organisation with potential for excellence in engineering and management


for the advancement of society and human kind.

Institute’s Mission

To excel in academics, practical engineering, Management and to


commence
research endeavours.
To prepare students for future
opportunities.
To nurture students with social and ethical
responsibilities.
Department’s Vision

To create IT graduates with ethical and employable skills.

Department’s Mission

To imbibe problem solving and analytical skills through teaching


learning Process.
To impart technical and managerial skills to meet the industry requirement.

To encourage ethical and value based education.


Excelssior’s Education Society

K. C. COLLEGE OF ENGINEERING
AND MANAGEMENT STUDIES AND
RESEARCH THANE (EAST).

Certificate

This is to certify that Mr. / Ms.


of Semester VIIITH Branch IT Roll No.

has performed and successfully completed all the practical’s in the subject of Blockchain
Lab for the academic year 2022 to 2023 as prescribed by University of Mumbai.

DATE: -

Practical In charge Internal Examiner

_
Head of Department External Examiner

COLLEGE SEAL
Lab Name Teaching Scheme Credits Assigned
Lab Code
(Contact Hours)

Theor Practic Tutori Theo Practic Tutor Total


y al al ry al & ial
Oral
ITL80 Blockchain -- 02 -- -- 01 -- 01
1 Lab

t
Lab Co Lab Name i
Theory Marks o
n
E
x S
a c
m h
i e
n m
a e
de Internal Term Work Total
End
assessment Pract. /Oral
m.
Test1 Test 2 Avg. E
xa
Blockchain Lab -- m
ITL801
-- -- 25
--
S
50
e 25
Lab Objectives:

Sr. Lab Objectives


No.
The Lab experiments aims:
1. To develop and deploy smart contracts on local Blockchain.
2. To deploy the smart contract on test networks.
3 To deploy and publish smart contracts on Ethereum test network.
4. To design and develop crypto currency.
5 To deploy chain code on permissioned Blockchain.

6 To design and develop a Full-fledged DApp using Ethereum/Hyperledger.

Lab Outcomes:
Sr. Lab Outcomes Cognitive
No. levels of
attainment as
per Bloom’s
Taxonomy
On successful completion, of course, learner/student will be able to:
1 Develop and test smart contract on local Blockchain. L3, L4
2 Develop and test smart contract on Ethereum test networks. L3,L4 L3, L4
3 Write and deploy smart contract using Remix IDE and Metamask. L4

4 Design and develop Cryptocurrency. L4

5 Write and deploy chain code in Hyperledger Fabric. . L4

6 Develop and test a Full-fledged DApp using Ethereum/Hyperledger. L5


Prerequisite: Programming Langauges.
S Module Detailed Content Hou LO
r. rs Mappi
N ng
o.
0 Prerequisite Java, Python, JavaScript 02 —

I Local Blockchain Local Blockchain Introduction to Truffle, 02 LO1


Introduction to establishing local Blockchain
Truffle, establishing Mini Project: Allocation of the groups
local Blockchain
II Smart contracts and Smart contracts and Solidity programming 04 LO2
chaincode language, chain code on Truffle local blockchain
Mini Project: Topic selection

III Deployment and Ethereum Test networks 04 LO3


publishing smart (Ropsten/Gorelli/Rinkeby), deployment on test
contracts on networks, Web3.js/Web3.py for interaction with
Ethereum test Ethereum smart contract
network Mini Project: Topic validation and finalizing
software requirements
IV Remix IDE and Smart contract development and deployment using 04 LO4
Metamask Metamask and Remix
Design and develop Crypto currency
Mini Project: Study the required programming
language for smart contract

V Chain code Chain code deployment in Hyperledger fabric 04 LO5


deployment in Mini project: Study required front end tools
Hyperledger Fabric

VI Mini-project on Implementation of Mini Project 06 LO6


Design and 1. Design, configure and testing of mini project
Development of a 2. Report submission as per guidelines
DApps using
Ethereum/Hyperledg
er Fabric
Mini project:
1. Students should carry out mini-project in a group of three/four students with a subject In-charge
2. The group should meet with the concerned faculty during laboratory hours and the progress of work discussed must be
documented.
3. Each group should perform a detailed literature survey and formulate a problem statement.
4. Each group will identify the hardware and software requirement for their defined mini project problem statement.
5. Design, develop and test their smart contract/chain code.
6. Each group may present their work in various project competitions and paper presentations
Documentation of the Mini Project
The Mini Project Report can be made on following lines:
1. Abstract
2. Contents
3. List of figures and tables
4. Chapter-1 (Introduction, Literature survey, Problem definition, Objectives, Proposed Solution, Technology/platform
used)
5. Chapter-2 (System design/Block diagram, Flow chart, Software requirements, cost estimation)
6. Chapter-3 (Implementation snapshots/figures with explanation, code, future directions)
7. Chapter-4 (Conclusion)
8. References
Term-Work: Term-Work shall consist of 5 experiments and Mini-Project on above guidelines/syllabus. Also, Term-
work must include at least 2 assignments and Mini-Project report.
Term Work Marks: 25 Marks (Total marks) =15 Marks (5 Experiments + Mini Project) + 5 Marks (Assignments) + 5
Marks
(Attendance)
Oral Exam: An Oral exam will be held based on the Mini Project and Presentation.
Program Outcomes

Engineering Graduates will be able to:

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.

2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated CONCLUSIONs using first principles of
mathematics, natural sciences, and engineering sciences.

3. Design/development of solutions: Design solutions for complex engineering problems


and design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid CONCLUSIONs.

5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.

6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.

7. Environment and sustainability: Understand the impact of the professional engineering


solutions in societal and environmental contexts, and demonstrate the knowledge of, and
need for sustainable development.

8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.

9. Individual and team work: Function effectively as an individual, and as a member or


leader in diverse teams, and in multidisciplinary settings.

10. Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give
and receive clear instructions.

11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.

12. Life-long learning: Recognize the need for, and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change.
Course Name: Blockchain Lab

Course Code: ITL801

Lab Lab
Code Outcomes
At the end of the course student will be able to:

ITL801.1 Develop and test smart contract on Ethereum test networks.

ITL801.2 To deploy the smart contract on test networks.

ITL801.3 Write and deploy smart contract using Remix IDE and Metamask.

ITL801.4 Design and develop Cryptocurrency.

ITL801.5 Write and deploy chain code in Hyperledger Fabric.

ITL801.6 Develop and test a Full-fledged DApp using Ethereum/Hyperledger. L5


Rubrics for Experiment

Subject: Blockchain Lab Lab (ITL801)

Class: BE Semester: VIII

Rubric Maximu 15-12 12- 9-6 6-0


s m 9
Descripti Marks
on Weight
Implementati 05 Successful Output Few errors Incorrect
on (R1) completio correct in the output
n with but not output
accurate precise
output (2-0)
(5-4) (4- (3-2)
3)
Understandi 0 Understan Understan Improp No
ng (R2) 5 d d er conclusi
experiment experimen conclusi on
and drawn t but on
correct conclusio
conclusion n less
accurate
(5-4) (4- (3-2) (2-0)
3)
Punctuali 05 Submissi Submissi Submissio Submissio
ty and on within on after a n after two n after
Disciplin a week week weeks three
e (R3) weeks or
(5-4) (3-2) more
(4- (2-0)
3)
TABLE OF
CONTENTS
S Name of Experiment Da Da Pa Gra Si
r. te te ge de gn
N of of N Mar
o Performa Submissi o. ks
nc e on
1 1. Write the program to
implement a Solidity
smart contract using array
and function in Remix IDE
with following functions

a. Creation of static
and dynamic array

b. Addition and
deletion of array
elements

c. Finding length of a
given array

d. Printing array
element in sorted
order

e. Searching a
particular element
in an array

2 Install a Metamask testnet. Use the


Metamask testnet for embedding
wallet and transferring ethers to
other wallets through a smart
contract.

3 To install Truffle & Ganache and


use Ethreum-Ganache to create
an account and illustrate using
solidity smart contract
compilation and development
environment
4 Deploy an Etherium Testnet and
use Web3.py for writing smart
contracts.

5 Write a chain-code application in


GO to alter the state of  a
distributed hyperledger fabric
account with assets; check to see if
the asset exists;  transfer assets
from one account wallet to
another. 

6 Design and develop a Blockchain


based referendum system with
Ethereum Blockchain. Based on
the result of the referendum a
series of steps have to be put in
pace through a smart contract.
(Innovative Experiment)

7 Case Study
Topic : Methodology of creating
your own crypto currency

8 Mini-Project
Total Grade / Marks:

Average marks of Average marks of Assignment Total Marks


Experiments

Obtained Out of Obtained Out of

Pracfical In-charge D
a
t
e
EXPERIMENT NO. 1

AIM: Write the program to implement a Solidity smart contract using array and function in Remix IDE with
following functions
a. Creation of static and dynamic array
b. Addition and deletion of array elements
c. Finding length of a given array
d. Printing array element in sorted order
e. Searching a particular element in an array

Lab Outcome: The student will be able to understand the


f. Significance and deployment of a smart contract
g. Writing of Solidity code in an IDE

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
Experiment No 1
1. Aim. Write the program to implement a Solidity smart contract using array and function in Remix IDE with
following functions
h. Creation of static and dynamic array
i. Addition and deletion of array elements
j. Finding length of a given array
k. Printing array element in sorted order
l. Searching a particular element in an array

2 Objective
a. To understand the concept of a smart contract.
b. To learn how to write programs in Solidity language.
c. To understand the Remix integrated development environment (IDE).

3 Outcomes. The student will be able to understand the


a. Significance and deployment of a smart contract
b. Writing of Solidity code in an IDE

4 Hardware / Platform / Software Required.

a. Windows 7 SP1, Internet Access


b. Processor: 1 gigahertz (GHz) or faster processor
c. RAM: 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit.
d. Hard disk space: 16 GB for 32-bit OS or 20 GB for 64-bit OS.
e. Remix IDE

5 Theory.
Solidity is a brand-new programming language created by Ethereum which is the second-largest market of
cryptocurrency by capitalization, released in the year 2015. Some key features of solidity are listed below: 
● Solidity is a high-level programming language designed for implementing smart contracts.

● It is a statically typed object-oriented(contract-oriented) language.


● Solidity is highly influenced by Python, c++, and JavaScript which run on the Ethereum Virtual
Machine(EVM).
● Solidity supports complex user-defined programming, libraries, and inheritance.

● Solidity is the primary language for blockchains running platforms.


● Solidity can be used to create contracts like voting, blind auctions, crowdfunding, multi-signature wallets, etc.

Smart Contract
1. Smart contracts are high-level program codes that are compiled to EVM byte code and deployed to the
ethereum blockchain for further execution.
2. It allows us to perform credible transactions without any interference of the third party, these transactions
are trackable and irreversible. Languages used to write smart contracts are Solidity (a language library with
similarities to C and JavaScript),

6 Procedure
● Version Pragma: 
o pragma solidity >=0.4.16 <0.9.0;
o Pragmas are instructions to the compiler on how to treat the code. All solidity source code should
start with a “version pragma” which is a declaration of the version of the solidity compiler this code
should use. This helps the code from being incompatible with the future versions of the compiler
which may bring changes. The above-mentioned code states that it is compatible with compilers of
version greater than and equal to 0.4.16 but less than version 0.9.0

● The contract keyword: 


o contract Test
o {
o //Functions and Data
o }
o The contract keyword declares a contract under which is the code encapsulated.

● State variables: 
o uint public var1;
o uint public var2;
o uint public sum;
o State variables are permanently stored in contract storage that they are written in Ethereum
Blockchain. The line uint public var1 declares a state variable called var1 of type uint (unsigned
integer of 256 bits). Think of it as adding a slot in a database. Similarly, goes with the
declaration uint public var2 and uint public sum.
● A function declaration:
o function set(uint x, uint y) public
o function get() public view returns (uint)
o This is a function named set of access modifier type public which takes a variable x and variable y
of datatype uint as a parameter.
o This was an example of a simple smart contract that updates the value of var1 and var2. Anyone
can call the function set and overwrite the value of var1 and var2 which is stored in the Ethereum
blockchain. This is an example of a decentralized application that is censorship-proof and
unaffected to the shutdown of any centralized server. As long as someone is running a single node
of the Ethereum blockchain, this smart contract will be accessible.
o The variable sum is calculated by adding the values of the variables var1 and var2.
o Function get will retrieve and print the value of the state variable sum.
● How to Execute The Code:
o Online Mode: Remix IDE is generally used to compile and run Solidity smart contracts in the
Online Mode.

7 Conclusion In this experiment we have learnt and demonstrated how to


a. Write a and deploy a smart contract in Solidity
b. How to work in the Remix IDE.

8 Viva Questions
a. What is an Ethereum smart contract?
b. What is the typical layout of a Solidity smart contract?
c. What are the 2 variable visibilities for state variables in Solidity?

9 References
a. Ethereum Smart Contract Development, Mayukh Mukhopadhyay, Packt publication.
b. Solidity Programming Essentials: A Beginner's Guide to Build Smart Contracts for Ethereum and Blockchain,
Ritesh Modi, Packt publication.
EXPERIMENT NO.2
AIM: Objective
a. To understand the concept of a smart contract.
b. To learn how to write programs in Solidity language.
c. To understand the Remix integrated development environment (IDE).

Lab Outcome: The student will be able to understand the


a. Significance and deployment of a smart contract
b. Writing of Solidity code in an IDE

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
Experiment No 2

1. Aim. Install a Metamask testnet. Use the Metamask testnet for embedding wallet and transferring ethers to other
wallets through a smart contract.
2. Objective
a. To understand the concept of a wallet in blockchains.
b. To learn how to implement and exchange crypto-currency through wallets.
c. To understand how Metamask is installed and used as a wallet.

3. Outcomes. The learner will be able to understand the


a. Significance of a wallet in blockchain transactions.
b. How to install a wallet on a testnet.
c. How to transfer crypto-currency from a wallet through a smart contract

4. Hardware / Platform / Software Required.


a. Windows 7 SP1, Internet Access
b. Processor: 1 gigahertz (GHz) or faster processor
c. RAM: 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit.
d. Hard disk space: 16 GB for 32-bit OS or 20 GB for 64-bit OS.
e. Metamask

5. Theory.
● Public blockchains like Ethereum are the next evolution of Internet databases, and MetaMask is the next
evolution of the browser.
● MetaMask is a web browser extension and mobile app that allows you to manage your Ethereum private
keys.
● It serrves as a wallet for Ether and other tokens, and allows you to interact with decentralized applications,
or dapps.
● Unlike some wallets, MetaMask keeps no personal information eg email address, password, Secret
Recovery Phrase or other private keys.
● The user retains all power over his crypto-identity.

6. Procedure
● Install MetaMask on your browser.

● To create a new wallet, you have to install the extension first.

● Depending on your browser, there are different marketplaces to find it, by referencing the appropriate
Metamask store in Chrome, Firefox, or Opera.
● Create an account.

● Click on the extension icon in the upper right corner to open

● MetaMask. You will be prompted to create a new password.

● Create a strong password for your wallet.Securely store the seed phrase for your walletClick on “Click here to

reveal secret words” to show the seed phrase.


● MetaMask requires that you store your seed phrase in a safe place. It is the only way to recover your funds

should your device crash or your browser reset.

● You can now access your wallet by clicking on the MetaMask icon at the top-right-end corner of your

preferred browser.

7. Conclusion In this experiment we have learnt and demonstrated how to


a. Install Metamask
b. Transfer crypto-currency into a wallet through a smart contract

8. Viva Questions
a. What is a crypto-wallett?
b. Why is a wallet required for blockchain tranactions?
c. What accounts can be accessed through smart contracts?

9. References
a. https://myterablock.medium.com/how-to-create-or-import-a-metamask-wallet-a551fc2f5a6b
b. Ethereum Smart Contract Development, Mayukh Mukhopadhyay, Packt publication.
c. Solidity Programming Essentials: A Beginner's Guide to Build Smart Contracts for Ethereum and
Blockchain, Ritesh Modi, Packt publication.
Experiment No 3

AIM: To install Truffle & Ganache and use Ethreum-Ganache to create an account and illustrate using
solidity smart contract compilation and development environment
Lab Outcome: The student will be able to understand
a. How to operate and work with the Truffle-Ganache Suit.
b. Deploying smart contracts through Truffle-Ganache.
c. How to transfer crypto-currency from a wallet through a smart contract in Ganache

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
Experiment No 3
1. Aim. To install Truffle & Ganache and use Ethreum-Ganache to create an account and illustrate using solidity
smart contract compilation and development environment
2. Objective
a. To understand how to work with the Truffle-Ganache Suite.
b. To learn how to write smart contracts through Truffle and Ganache
c. To understand how to transfer currency through a contract.

3. Outcomes. The student will be able to understand


a. How to operate and work with the Truffle-Ganache Suit.
b. Deploying smart contracts through the Truffle-Ganache.
c. How to transfer crypto-currency from a wallet through a smart contract in Ganache

4. Hardware / Platform / Software Required.


a. Windows 7 SP1, Internet Access
b. Processor: 1 gigahertz (GHz) or faster processor
c. RAM: 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit.
d. Hard disk space: 16 GB for 32-bit OS or 20 GB for 64-bit OS.
e. Node.js v14 - v18

5. Theory.
a. Ganache is a component of the Truffle Suite framework
b. Truffle serves as the development environment, testing framework and asset pipeline based on the
Ethereum Virtual Machine. 
c. Ganache allows the user to create a private Ethereum blockchain to run tests, execute commands, and
inspect state while controlling how the chain operates. 
d. Many developers use this to test their smart contracts during development.
e. Ganache provides convenient tools such as advanced mining controls and a built-in block explorer.
f. Truffle is a developer environment, testing framework and asset pipeline for blockchains
6. Procedure
a. Install Ganache first. Ganache is a personal blockchain for Ethereum development.
b. It is available for download from https://www.trufflesuite.com/ganache, the official website.
c. Install Truffle Suite:
d. On Truffle Suite, set up an Ethereum programming framework.
e. Create your smart contract using Solidity: The final step is to create your smart contract.
f. In the contracts/ directory that Truffle created when you started the project, you can make a new Solidity
file.

7. Conclusion In this experiment we have learnt and demonstrated how to


a. Install Truffle / Ganache
b. Write smart contracts in Solidity on the Truffle platform

8. Viva Questions
a. What is the difference between Truffle & Ganache?
b. What is the input to the Ethereum Virtual Machine?
c. What is ‘smart’ about a smart contract?

9. References
a. https://www.freecodecamp.org/news/getting-started-with-truffle/
b. Ethereum Smart Contract Development, Mayukh Mukhopadhyay, Packt publication.
c. Solidity Programming Essentials: A Beginner's Guide to Build Smart Contracts for Ethereum and
Blockchain, Ritesh Modi, Packt publication.
EXPERIMENT NO. 4
Aim. Deploy an Etherium Testnet and use Web3.py for writing smart contracts.

Outcomes. The student will be able to understand


a. How to develop Web3.py applications on an Ethereun testnet.
b. How to write smart contracts in Python

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
Experiment No 4
1. Aim. Deploy an Etherium Testnet and use Web3.py for writing smart contracts.
2. Objective
a. To understand how to write smart contracts with python code.
b. To learn how to deploy python smart contract on an ethereum testnet.

3. Outcomes. The student will be able to understand


c. How to develop Web3.py applications on an Ethereun testnet.
d. How to write smart contracts in Python

4. Hardware / Platform / Software Required.


a. Windows 7 SP1, Internet Access
b. Processor: 1 gigahertz (GHz) or faster processor
c. RAM: 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit.
d. Hard disk space: 16 GB for 32-bit OS or 20 GB for 64-bit OS.
e. Node.js v14 - v18

5. Theory.
● Web3.py is a set of libraries that allow developers to interact with Ethereum nodes using HTTP, IPC,
or WebSocket protocols with Python.
● Moonbeam has an Ethereum-like API available that is fully compatible with Ethereum-style JSON
RPC invocations.
● Students can leverage this compatibility and use the Web3.py library to interact with a Moonbeam
python3 as if they were doing so on Ethereum.Procedure

6. Procedure
● Create a Python Project

● Setup Web3.py with Moonbeam

● Import the rpc_gas_price_strategy which will be used in the following steps to get the gas
price used for the transactionSet up the Web3 provider
● Define the account_from, including the private_key, and the address_to variables.

● The private key is required to sign the transaction

● Use the Web3.py Gas Price API to set a gas price strategy.

● For this example, you'll use the imported rpc_gas_price_strategy

● Create and sign the transaction

● Pass in the nonce gas, gasPrice, to, and value for the transaction along with the


sender's private_key.
● To get the nonce you can use the web3.eth.get_transaction_count function and pass in
the sender's address.
● To predetermine the gasPrice you'll use the web3.eth.generate_gas_price function.

● Using the signed transaction, you can then send it using


the web3.eth.send_raw_transaction function and wait for the transaction receipt by using
the web3.eth.wait_for_transaction_receipt function

7. Conclusion In this experiment we have learnt and demonstrated how to


● Use Web3.py applications

● Write smart contracts in Python

8. Viva Questions
● What is the use of ‘gas’ in ethererum?

● What is s Dapp?

● What is the difference between Python and Solidity?

9. References
● https://docs.moonbeam.network/builders/build/eth-api/libraries/web3py/

● Ethereum Smart Contract Development, Mayukh Mukhopadhyay, Packt publication.

● Solidity Programming Essentials: A Beginner's Guide to Build Smart Contracts for Ethereum and
Blockchain, Ritesh Modi, Packt publication.
EXPERIMENT NO. 5

AIM: Write a chain-code application in GO to alter the state of  a distributed hyperledger fabric account with
assets; check if the asset exists;  transfer assets from one account wallet to another. 

Outcomes. The student will be able to understand


a. How to write smart contracts on hyperledger fabric platform
b. How to write smart contracts in GO(LANG)

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
Experiment No 5

1. Aim. Write a chain-code application in GO to alter the state of  a distributed hyperledger fabric account with
assets; check to see if the asset exists;  transfer assets from one account wallet to another. 
2. Objective
a. To understand how to create a hyperledger facric network
b. To learn how to incorporate security in the network node transactions.
c. To transfer crypto-assets by using GO language (GOLANG) through the channel approach.

3. Outcomes. The learner will be able to understand


a. How to write smart contracts on hyperledger fabric platform
b. How to write smart contracts in GO(LANG)

4. Hardware / Platform / Software Required.


f. Windows 7 SP1, Internet Access
g. Processor: 1 gigahertz (GHz) or faster processor
h. RAM: 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit.
i. Hard disk space: 16 GB for 32-bit OS or 20 GB for 64-bit OS.
j. Node.js v14 - v18

5. Theory.

● Hyperledger Fabric is an open source enterprise-grade platform that leverages a highly-modular and
configurable architecture.
● Hyperledger Fabric is optimized for a broad range of industry use cases, including the finance, banking,
healthcare, insurance, and public sectors, as well as supply chains and digital asset management.
● Hyperledger Fabric supports Smart Contact development in general-purpose programming languages,
such as JavaScript, Java, Go, and Node.js.
● Hyperledger Fabric is also operating under a governance model to build trust between participants on a
shared network.

6. Procedure

● Setting up Fabric CA server

● Launch 2 fabric CA servers, one for CA and one for TLSCA

● Start the servers using the docker-compose.

● The four compulsory folders are:-


admincerts:- we need to manually make this folder and put admin’s CA cert in it, we will generate admin
certificate and put it in it.
 cacerts:- Automatically created by fabric CA while generating certs.
signcerts:- Automatically created by fabric CA while generating certs.
keystore:- Automatically created by fabric CA while generating certs.
● Generate the TLS certificates

● Create and sign the transaction

● Generate a genesis block and a channel


● Bring up the network.

● Create and join the channels

● Check if all the containers and up and running

7. Conclusion In this experiment we have learnt and demonstrated how to


● Create a hyperledger fabric network using serevers using GOLANG.

● Set security settings

● Implement a channel mechanism

8. Viva Questions
a. What is the use of permissioned blockchains?
b. What is a channel in hyperledger?
c. How does hyperledger provide enhanced security for a blockchain?

9. References
a. https://hyperledger-fabric.readthedocs.io/en/release-2.1/chaincode4ade.html
b. https://github.com/habpygo/Hyperledger-Fabric-chaincode
c. https://medium.com/coinmonks/creating-a-hyperledger-fabric-network-from-scratch-v-1-4-695906dbb7c6
EXPERIMENT NO: 6
(Innovative Experiment)

AIM: : Design and develop a Blockchain based referendum system with Ethereum
blockchain. Based on the results of the referendum, a series of steps have to be executed
through a smart contract.

Lab Outcomes. The student will be able to understand


a. Understand the utility of blockchain for society
b. Practice skills of design of blockchain application
c. Enhance write smart contracts in Ethereum

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
Experiment No 6
(Innovative Experiment)
1. Aim. Design and develop a Blockchain based referendum system with Ethereum Blockchain. Based on the result of
the referendum a series of steps have to be put in pace through a smart contract..
2. Objectives
a. To design a referendum (polling) scheme based on the technology of an Ethereum smart contract.
b. To implement and test such a scheme.
c. To execute some contract based on the result of the scheme
d. To study the feasibility.

3. Outcomes. The student will be able to understand


a. Understand the utility of blockchain for society
b. Practice skills of design of blockchain application
c. Enhance smart contract writing skills in Ethereum

4. Hardware / Platform / Software Required.


a. Windows 7 SP1, Internet Access
b. Processor: 1 gigahertz (GHz) or faster processor
c. RAM: 1 gigabyte (GB) for 32-bit or 2 GB for 64-bit.
d. Hard disk space: 16 GB for 32-bit OS or 20 GB for 64-bit OS.
e. Node.js v14 - v18

5 Theory.
● Blockchain innovation is one arrangement that can be utilized in light of the fact that it has a
decentralized framework and the whole database is duplicated by all clients.
● Blockchain itself has been used by Bitcoin and Ethereum cryptocurrency which is known as a
decentralized system.
● By using the blockchain in database recording on an e-voting system can reduce one source of fraud
that is database manipulation.
● Other advantages of blckchain like immutability, transparency and security can also be accrued.

● The user's identity preserving the transparency and integrity of data while preventing the duplication or
manipulation of votes in any way by any external factors

5. Procedure
a. Install Truffle.
b. Develop the directory structure as follows
● contracts/ — Folder holding all of the Contracts. (never to be deleted)

● migrations/ — Folder holding Migration files, which deploy smart contracts into the
Blockchain.
● src/ — holds the HTML/CSS and Javascript files for the application

● truffle.js — Truffle Configuration file

● build/ — Not require till compilation of contracts. This folder holds the build artifacts. Build
artifacts describe the function and architecture of contract and give Truffle Contracts and web3
information on how to interact with smart contracts in the blockchain.

c. Write the smart contract incorporating


● State Variables — variables that hold values that are permanently stored on the Blockchain. Use
state variables to hold a list and number of Voters and Candidates.
● Functions — Functions are the executables of smart contracts. They called to interact with the
Blockchain, and they have different levels of visibility, internally and externally.
● Events — Whenever an event is called, the value passed into the event will be logged in the
transaction’s log. This allows Javascript callback functions or resolved promises to view the certain
value you wanted to pass back after a transaction. This is because every time a transaction is made,
a transaction log will be returned.
● Struct Types — This is very similar to a C struct.
d. Instantiate web3 and contracts
e. Extend functionality by App,start(), App.Vote , App. CountNoofVotes

6. Conclusion In this experiment we have learnt and demonstrated how to


a. Uses of blockchain for society
b. Design a smart contract for carrying out referndums and executing smart contracts on Ethereum
platform
c. Implement such an application

7. Viva Questions

a. What are the uses of blockchain in other live domains?


b. What are the disadvantages of online polls?
c. How is anonymity assured in this configuration?

8. References
a. https://www.ijraset.com/research-paper/e-voting-using-ethereum-blockchain
b. https://www.freecodecamp.org/news/developing-an-ethereum-decentralized-voting-application-
a99de24992d9/
c. Ethereum Smart Contract Development, Mayukh Mukhopadhyay, Packt publication.
d. Solidity Programming Essentials: A Beginner's Guide to Build Smart Contracts for Ethereum and
Blockchain, Ritesh Modi, Packt publication.
Experiment 7

Case Study
Topic : Methodology of creating your own crypto currency

Lab Outcome: To be able to understand, analyze, and apply the learning from research and learning and
record it as a body of knowledge for subsequent reference, analysis, and use.

Date of Performance:

Date of Submission:

Implementati Understandi Punctuality & Total


on (05) ng (05) Discipline Mark
(05) s (15)

Practical Incharge
EXPERIMENT NO: 7

Experiment 7
Case Study

1. Topic : Methodology of creating your own crypto currency


2. Outcome : To be able to understand, analyze, and apply the learning from research and learning and record it
as a body of knowledge for subsequent reference, analysis, and use.
3. Introduction: As per the Google search engine, there are currently more than 22,904 cryptocurrencies in
existence. However, not all cryptocurrencies are active or valuable. Discounting many “dead” cryptos leaves
only around 8,832 active cryptocurrencies. There are upwards of 300 million crypto-currency users across the
globe. And approximately 18,000 businesses now accept a form of crypto as payment. The discussion of the
points to kept in mind while designing a crypto-currency will improve our overall understanding of the study
domain.
4. Relevant Points: The main point to consider while developing a crypto-currency are:
a. What is a cryptocurrency?
b. A crypto-currency, also known as crypto, is a type of digital asset with multiple use cases. It's primarily
a way to transfer value between people digitally, including monetary value, ownership rights, or even
voting privileges. Crypto differs from other digital payment systems because of its roots in blockchain
technology. This basis gives cryptocurrencies more freedom from central entities like governments or
banks.Bitcoin is the most famous example of a cryptocurrency. It has a simple use case of transferring
monetary value to anyone across the globe without the need for intermediaries. Its blockchain records
all transactions and ensures security and network stability.

c. What is the Difference between crypto coins and tokens in Crpto-currencies?


i. Cryptocurrencies can roughly be split into two categories: coins and tokens. The difference
between them is simple. Coins have their own native blockchain, like Bitcoin, for example.
Ether (ETH) has the Ethereum blockchain. Coins typically have a specific utility over the whole
network, like paying for transaction fees, staking, or taking part in governance.
5. What is the utility of the cryptocurrency?
a. Cryptocurrencies can play many roles. Some act like keys to access services. Others even represent
stocks or other financial assets. To understand and map out the process of creating your crypto, you'll
need to define its features from the beginning.
b. Tokenomics are the economics that govern your crypto, like total supply, distribution method, and
initial pricing. A good idea can fail if the tokenomics aren't correct and users aren't incentivized to
purchase the cryptocurrency. For example, if you're creating a stablecoin but cannot peg it correctly, no
one will want to buy or hold it.
6. Check its legal compliance Countries around the world have their own laws and rules regarding
cryptocurrencies. Some jurisdictions may even ban the use of cryptocurrencies. Consider fully your legal
obligations and any compliance issues you might face.

7. Choose a suitable blockchain platform


a. For a token, you'll need to pick the blockchain to mint your crypto on. BSC and Etheruem are popular
options, but sidechains can also be a good idea. To create your own coin, you'll need to think about
designing or hiring someone to create a custom blockchain.
8. Pick a consensus mechanism
If you're creating your own blockchain or aren't sure which one to pick for your token, think about
the consensus mechanism you want. These mechanisms determine how participants confirm and
validate transactions on the network. Most blockchains use Proof of Stake as it has low hardware
requirements and many different variations. Proof of Work, as used in Bitcoin, is considered by some
as more secure but it’s often expensive to maintain and not as environmentally friendly.
9. Design your blockchain architecture
This step is only needed if you're creating a coin. Not every blockchain allows the public to validate
transactions or run nodes. The decision between having a private, public, permissioned, or
permissionless blockchain is important. Your blockchain architecture will depend on what your coin
and project are attempting to do. For example, a company or country creating a coin might run a
private blockchain for more control.
10. Begin blockchain development
A blockchain is built on ideas and protocols . Once the blockchain runs in a live environment, it's
extremely difficult to change its core concepts and rules. Make use of a testnet to ensure that
everything works as planned and ideally cooperate with a whole development team to build your
blockchain. 
11. Minting the cryptocurrency
Whether you're creating a token or coin, you will need to mint the cryptocurrency at some point. The
exact method will differ based on your tokenomics. For example, fixed supply tokens are usually
minted all in one go via a smart contract. Coins like Bitcoin are minted gradually, as miners validate
new blocks of transactions.
Mini-Project
Note that:
1. Students should carry out mini-project in a group of three/four students with a subject In-charge
2. The group should meet with the concerned faculty during laboratory hours and the progress of work
discussed must be documented.
3. Each group should perform a detailed literature survey and formulate a problem statement.
4. Each group will identify the hardware and software requirement for their defined mini project problem
statement.
5. Design, develop and test their smart contract/chain code.
6. Each group may present their work in various project competitions and paper presentations.

Documentation of the Mini Project


The Mini Project Report can be made on following lines:
1. Abstract
2. Contents
3. List of figures and tables
4. Introduction, Literature survey, Problem definition, Objectives, Proposed Solution, Technology/platform
used
5. System design/Block diagram, Flow chart, Software requirements, cost estimation
6. Implementation snapshots/figures with explanation, code, future directions
7. Conclusion
8. References

You might also like