Lab Manual Blockchain Lab
Lab Manual Blockchain Lab
Lab Manual Blockchain Lab
Institute’s Mission
Department’s Mission
K. C. COLLEGE OF ENGINEERING
AND MANAGEMENT STUDIES AND
RESEARCH THANE (EAST).
Certificate
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: -
_
Head of Department External Examiner
COLLEGE SEAL
Lab Name Teaching Scheme Credits Assigned
Lab Code
(Contact Hours)
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:
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
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.
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.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
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
Lab Lab
Code Outcomes
At the end of the course student will be able to:
ITL801.3 Write and deploy smart contract using Remix IDE and Metamask.
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
7 Case Study
Topic : Methodology of creating
your own crypto currency
8 Mini-Project
Total Grade / Marks:
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
Date of Performance:
Date of Submission:
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).
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.
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
● 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.
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).
Date of Performance:
Date of Submission:
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.
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.
● 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.
● Create a strong password for your wallet.Securely store the seed phrase for your walletClick on “Click here to
● You can now access your wallet by clicking on the MetaMask icon at the top-right-end corner of your
preferred browser.
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:
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.
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.
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.
Date of Performance:
Date of Submission:
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.
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
● 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.
8. Viva Questions
● What is the use of ‘gas’ in ethererum?
● What is s Dapp?
9. References
● https://docs.moonbeam.network/builders/build/eth-api/libraries/web3py/
● 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.
Date of Performance:
Date of Submission:
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.
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
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.
Date of Performance:
Date of Submission:
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.
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
● 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.
7. Viva Questions
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:
Practical Incharge
EXPERIMENT NO: 7
Experiment 7
Case Study