0% found this document useful (1 vote)
309 views23 pages

BT Lab Manual

This document is the lab manual for the course "Laboratory Practice III (Blockchain Technology)" for BE Computer students in 2022-23 semester 1. It was prepared by Mrs. Sonia Waghmare and contains 4 assignments on topics like installing Metamask, creating a crypto wallet, writing a smart contract for bank account operations, and writing a program to create student data using Solidity constructs like structures and arrays. The document provides theory and outcomes for each assignment.

Uploaded by

Rutuja Gurav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
309 views23 pages

BT Lab Manual

This document is the lab manual for the course "Laboratory Practice III (Blockchain Technology)" for BE Computer students in 2022-23 semester 1. It was prepared by Mrs. Sonia Waghmare and contains 4 assignments on topics like installing Metamask, creating a crypto wallet, writing a smart contract for bank account operations, and writing a program to create student data using Solidity constructs like structures and arrays. The document provides theory and outcomes for each assignment.

Uploaded by

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

BT Lab Manual ,BE Computer, 2022-23, Semester I

Marathwada Mitra Mandal’s

College of Engineering, Pune


Karve Nagar,Pune-411 052

Department of Computer Engineering

Lab Manual

Laboratory Practice III


(Blockchain Technology)
410246

Prepared by,

Mrs. Sonia Waghmare

Asst. Professor, Computer Engg

BE COMPUTER

2019 Pattern
BT Lab Manual ,BE Computer, 2022-23, Semester I

410246: Laboratory Practice III


BT Lab Manual ,BE Computer, 2022-23, Semester I

Assignment No. 1

TITLE: Installation of Metamask and study spending Ether per transaction.

OBJECTIVE: Learn what is Metamask and how the ether transaction is done.

OUTCOME: Install the metamask successfully.

THEORY:

● MetaMask is a cryptocurrency wallet that enables users to store Ether and other ERC-20 tokens.
● The wallet can also be used to interact with decentralized applications, or dapps.

By connecting to MetaMask to Ethereum-based dapps, users can spend their coins in games, stake
tokens in gambling applications, and trade them on decentralized exchanges (DEXs). It also
provides users with an entry point into the emerging world of decentralized finance, or DeFi,
providing a way to access DeFi apps such as Compound and PoolTogether.

MetaMask is one of the simpler Ethereum wallets and dapp browsers to use, and can be set up in a
couple of minutes in most cases.

First, you’ll need to download and install the official Metamask extension (also known as a plugin
or add-on) for your chosen browser. For most people, this is theGoogle Chrome extension or
the Firefox addon. For our guide, we’ll be using the Firefox version, but the steps are nearly
identical for other browsers.
BT Lab Manual ,BE Computer, 2022-23, Semester I

CONCLUSION: Hence we have successfully installed Metamask.

FAQS:

Did you know?


MetaMask has integrated with hardware wallets including Trezor and Ledger so that users can
use the service while keeping their crypto on a hardware wallet.
Why do we need metamask?
.

Is Metamask safer than Coinbase?

Is Metamask the best wallet?


.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Assignment No. 2

TITLE: Create your own wallet using Metamask for crypto transactions.

OBJECTIVE: Create a wallet to perform crypto transation.

OUTCOME: Create a wallet to perform crypto transation.

THEORY:
Once installed, you should see the below splash screen. Click the ‘Get Started’ button to begin
creating your Ethereum wallet using MetaMask.

On the next step, click the ‘Create a Wallet’ button.

then be asked if you want to help improve MetaMask. Click ‘No Thanks’ if this doesn’t interest you,
otherwise click ‘I agree’.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Pick a password on the next step. This needs to be at least 8 characters long. We recommend using a
completely unique password that hasn’t been used anywhere else, and one that contains a mixture of
upper and lower case letters, symbols, and numbers.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Read and accept the Terms of Use, and click ‘Create’ once your password has been set.
MetaMask will then present you with your 12-word backup phrase. You’ll need to write this phrase down
carefully, with the words recorded in the same order displayed on your screen. This phrase will be needed
to recover your wallet should you ever lose access to your computer, and should be kept stored somewhere
safe. Anybody who has access to your 12-word backup phrase will have access to the funds in your
MetaMask wallet, so keep it private.
Click ‘Next’ once you’ve written this down.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Confirm your backup phrase on the next screen by entering the words in the same order saved previously.
Click ‘Confirm’ once done.
BT Lab Manual ,BE Computer, 2022-23, Semester I

You have now almost completed the MetaMask setup process. Just click ‘All Done’ on the final page, and
you will be automatically logged in to MetaMask.
If you ever get logged out, you’ll be able to log back in again by clicking the MetaMask icon, which will
have been added to your web browser (usually found next to the URL bar).

CONCLUSION: Hence , We have Successfully Created sa wallet to perform crypto transation.

FAQS:

What advantages does MetaMask have?

What disadvantages does it have?

What are the alternatives to MetaMask?


BT Lab Manual ,BE Computer, 2022-23, Semester I
BT Lab Manual ,BE Computer, 2022-23, Semester I

Assignment No. 3

TITLE: Write a smart contract on a test network, for Bank account of a customer for following operations:

 Deposit money

 Withdraw Money

 Show balance

OBJECTIVE: creating a bank account by using crypto wallet and money deposit , withdraw and balance
checking is being performed.

OUTCOME:

pragma
solidit
y
^0.6.6;

contract BankContract {

struct client_account{
int client_id;
address client_address;
uint client_balance_in_ether;
}

client_account[] clients;

int clientCounter;
address payable manager;
mapping(address => uint) public interestDate;

modifier onlyManager() {
require(msg.sender == manager, "Only
manager can call this!");
_;
}
BT Lab Manual ,BE Computer, 2022-23, Semester I

modifier onlyClients() {
bool isclient = false;
for(uint i=0;i<clients.length;i++){
if(clients[i].client_address ==
msg.sender){
isclient = true;
break;
}
}
require(isclient, "Only clients can call
this!");
_;
}

constructor() public{
clientCounter = 0;
}

receive() external payable { }

function setManager(address managerAddress)


public returns(string memory){
manager = payable(managerAddress);
return "";
}

function joinAsClient() public payable


returns(string memory){
interestDate[msg.sender] = now;

clients.push(client_account(clientCounter++,
msg.sender, address(msg.sender).balance));
return "";
}

function deposit() public payable onlyClients{

payable(address(this)).transfer(msg.value);
}
BT Lab Manual ,BE Computer, 2022-23, Semester I

function withdraw(uint amount) public payable


onlyClients{
msg.sender.transfer(amount * 1 ether);
}

function sendInterest() public payable


onlyManager{
for(uint i=0;i<clients.length;i++){
address initialAddress =
clients[i].client_address;
uint lastInterestDate =
interestDate[initialAddress];
if(now < lastInterestDate + 10
seconds){
revert("It's just been less than
10 seconds!");
}
payable(initialAddress).transfer(1
ether);
interestDate[initialAddress] = now;
}
}

function getContractBalance() public view


returns(uint){
return address(this).balance;
}
}

CONCLUSION: Hence , We have successfully created Smart contract on a test network, for Bank account
of a customer for following operations are also performed

 Deposit money

 Withdraw Money

 Show balance
BT Lab Manual ,BE Computer, 2022-23, Semester I
BT Lab Manual ,BE Computer, 2022-23, Semester I

Assignment No. 4

TITLE:Write a program in solidity to create Student data. Use the following constructs:

 Structures

 Arrays

 Fallback

Deploy this as smart contract on Ethereum and Observe the transaction fee and Gas values

Objective: Understand and explore the working of Blockchain Technology and its applications.

Course Outcome:

CO6: Interpret the basic concepts in Blockchain technology and its applications.

Theory :

Solidity is an object-oriented, high-level language for implementing smart contracts. Smart contracts
are programs which govern the behaviour of accounts within the Ethereum state.

Following are the some constructs of solidity:

1. Structures :

Struct

Structs in Solidity allows you to create more complicated data types that have multiple
properties. You can define your own type by creating a struct. They are useful for grouping
together related data.

Structs can be declared outside of a contract and imported in another contract. Generally, it is used
to represent a record. To define a structure struct keyword is used, which creates a new data type.

Syntax:
BT Lab Manual ,BE Computer, 2022-23, Semester I

For accessing any element of the structure, ‘dot operator’ is used, which separates the struct
variable and the element we wish to access. To define the variable of structure data type structure
name is used
BT Lab Manual ,BE Computer, 2022-23, Semester I

2.Arrays :

Arrays are data structures that store the fixed collection of elements of the same data types in
which each and every element has a specific location called index. Instead of creating numerous
individual variables of the same type, we just declare one array of the required size and store the
elements in the array and can be accessed using the index. In Solidity, an array can be of fixed
size or dynamic size. Arrays have a continuous memory location, where the lowest index
corresponds to the first element while the highest represents the last

Creating an Array

To declare an array in Solidity, the data type of the elements and the number of elements should
be specified. The size of the array must be a positive integer and data type should be a valid
Solidity type

Syntax:

Fixed-size Arrays

The size of the array should be predefined. The total number of elements should not exceed the
size of the array. If the size of the array is not specified then the array of enough size is created
which is enough to hold the initialization.

Dynamic Array:

The size of the array is not predefined when it is declared. As the elements are added the size of
array changes and at the runtime, the size of the array will be determined

Array Operations

1. Accessing Array Elements: The elements of the array are accessed by using the index.
If you want to access ith element then you have to access (i-1)th index.

2. Length of Array: Length of the array is used to check the number of elements present in
an array. The size of the memory array is fixed when they are declared, while in case the
dynamic array is defined at runtime so for manipulation length is required.

3. Push: Push is used when a new element is to be added in a dynamic array. The
new element is always added at the last position of the array.

4. Pop: Pop is used when the last element of the array is to be removed in any dynamic array.

3. Fallback :

The solidity fallback function is executed if none of the other functions match the function identifier
or no data was provided with the function call. Only one unnamed function can be assigned to a
contract and it is executed whenever the contract receives plain Ether without
BT Lab Manual ,BE Computer, 2022-23, Semester I

any data. To receive Ether and add it to the total balance of the contract, the fallback function
must be marked payable. If no such function exists, the contract cannot receive Ether through
regular transactions and will throw an exception.

Properties of a fallback function:

1. Has no name or arguments.

2. If it is not marked payable, the contract will throw an exception if it receives plain
ether without data.

3. Can not return anything.

4. Can be defined once per contract.

5. It is also executed if the caller meant to call a function that is not available

6. It is mandatory to mark it external.

7. It is limited to 2300 gas when called by another function. It is so for as to make


this function call as cheap as possible.

Conclusion : In this way we studied what is smart contract and how to create smart contract
for student data using different constructs.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Assignment No. 5

TITLE:Write a survey report on types of Blockchains and its real time use cases.

Blockchain Technology is a shared database that keeps track of a given collection of transactions. Groups
of transactions comprise a block, the contents of which can never be changed. Each block is timestamped
and joined to the filled block before it with another block joined behind it when it becomes filled with
data, forming what is known as a blockchain. Its most common use is as a distributed ledger wherein all
participants agree on each transaction's "truth" and verify the legitimacy of the transaction before it
becomes a permanent record in a block.

Top blockchain use cases

Blockchain is "a general-purpose technology, which means it is applicable across sectors," said Christos
Makridis, a research professor at Arizona State University, senior adviser at Gallup, digital fellow at
Stanford University's Digital Economy Lab and CTO at arts and education technology startup Living
Opera. "For example, financial services can use it to write smart contracts between consumers and their
banking institution. Similarly, healthcare can use it to write smart contracts between insurers and hospitals,
as well as between patients and hospitals. The possibilities are endless."

1. Smart contracts: The primary function of computer programs called "smart contracts" is to automate the
execution of contract terms when conditions warrant them. The computer code follows a relatively simple
command of "when/if _then___" to ensure that all parties receive the benefits or penalties as the contract
stipulates and actions require. Smart contracts are useful to, and used by, most industries today for a
variety of uses traditionally governed by paper contracts. The blockchain also makes a permanent record
of every action and reaction in the transaction.
2. Cybersecurity: Blockchains are highly secure because of their permanency, transparency and distributed
nature. With blockchain storage, there's no central entity to attack and no centralized database to breach.
Because blockchains are decentralized, including those privately owned, and the data stored in each block
is unchangeable, criminals can't access the information. "Essentially, the intruder needs keys to many
different locations versus just one," Makridis noted. "The computing requirements for the intruder grow
exponentially."
3. IoT: Two primary IoT uses of blockchains are in the supply chain sector and for asset tracking and
inventory management. A third use is in recording measurements made by machines whether those sensors
are in the Artic, the Amazon jungle, a manufacturing plant or on a NASA drone surveying Mars. "Whether
it be reports of chemical data regarding oil grades or tracking shipments of electronics across the world
BT Lab Manual ,BE Computer, 2022-23, Semester I

through various ports of entry, the blockchain can be utilized anywhere there is data interacting with the
real world," explained Aaron Rafferty, CEO of cryptocurrency investment firm R.F. Capital.
4. Cryptocurrencies: The blockchain concept was originally developed to manage digital currencies such
as bitcoin. While the two technologies still compete against each other in alternative transactions, they've
also been separated so blockchains could serve other purposes. Given the anonymity of crypto coins,
blockchain is the only way to document transactions with accuracy and privacy for the parties involved.
5. NFTs: Nonfungible tokens are units of data certified to be unique and not interchangeable. In short, they
are digital assets. According to Rafferty, NFTs are revolutionizing the digital art and collectibles world.
"We are using decentralization and the ethereum blockchain to create a music live stream network where
artists and streamers can connect with fans directly, sell their NFTs, receive contributions from fans and
trade in their rewards and contributions for crypto tokens," said Shantal Anderson, founder and CEO of
music and pop culture streaming network Reel Mood.

Real-world industry blockchain applications

Here are some notable applications of blockchain in the public and private sectors, including government,
healthcare, financial and banking services, supply chains and media.

Healthcare

The possibilities for blockchain use in healthcare seem endless. "There are a number of potential use cases:
managing electronic medical record data, protecting healthcare data, safeguarding genomics information
and tracking disease and outbreaks, to name some," said David Brown, science and program director at
Qatar Precision Medicine Institute.

Precision medicine is medicine matched to a patient's genomics to improve results and lessen or eliminate
side effects. It also encompasses genomic-based medicines that are so badly needed as infectious agents
become increasingly resistant to antibiotics."Blockchain," Brown explained, "allows healthcare providers
and researchers to develop groundbreaking drugs and therapies based on genomic profiles."

Government

There are many blockchain use cases in various government agencies, including voting applications and
personal identification security.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Blockchains can't be forged nor the data within them manipulated. They can "hold digital IDs, certificates
of any kind, even passports on its immutable ledger," Rafferty said. "This data can be accessed and viewed
at any time in a completely transparent manner, which will bolster international travel
industries."Similarly, voting on-chain in a truly decentralized and transparent manner eliminates the
middleman and any question of voting manipulation or fraud.

Financial services

Blockchain is used in many types of financial applications. Trade finance, for example, "is riddled with
multiple steps and concurrent processes that can dramatically elongate transaction timelines," Agarwal
explained. With blockchain, he added, the entire process is "simplified with a bidirectional data flow. This
streamlines the trade finance transaction for each participant and "dramatically reduces the time to close
from 10 to 12 weeks to approximately one week."

Banking

EY's Zur said he expects business-to-business enterprise clients that "have contractually driven, multiparty
cash flow distributions" to use blockchain to "help them automate contract-related calculations and
processing."

Still considered to be far from a mature technology, blockchain is already used in many real-world banking
applications, "including contract management, real-time transparency, calculations and reporting,
inventory management, procurement, funds traceability, lending and borrowing, digitizing assets,
cryptocurrencies, reconciliation and settlements [for securities and commodity trades], and secure land
registries," EY's Kapur said.

Supply chain management

Before the COVID-19 pandemic disrupted supply chains worldwide, supply chains were the hottest
blockchain application -- and now even more so.

Blockchain is a good fit because "complex global supply chains have no central authority" and "lack
visibility," reasoned Nir Kshetri, a professor at the University of North Carolina-Greensboro and research
fellow at Kobe University.
BT Lab Manual ,BE Computer, 2022-23, Semester I

Companies involved in a supply chain, Kshetri added, can "benefit from transparency, commercial
confidentiality of data and an immutable record of transactions. For these reasons, the Netherlands-based
market intelligence platform Blockdata's analysis found that traceability and provenance supply chains
were the most popular blockchain use case among the world's biggest brands in 2020."

Media and entertainment

Media and entertainment is a rich arena for blockchain use, and the applications are as imaginative as the
industry.

"Even in the business side," Rafferty said, "a company can mint tickets to a football game or concert to a
major artist tour on-chain and set parameters so that, every time the ticket is resold on the second-hand
market, the team or artist collects royalties on those transactions set at a percentage that they determine
during the minting process."

Another example of a successful use case is EY and Microsoft's blockchain-based product for gaming
rights and royalties management, "which provides a financial system of record, from contract creation to
payment reconciliation," Zur said. Microsoft plans to use the expanded blockchain functions to "enable its
Xbox gaming partners and its network of artists, musicians, writers and other content creators to gain
increased visibility into tracking, management and payment processing for royalty contracts."

Conclusion : Hence we have successfully studied survey reports on types of Blockchains and its
real time use cases.

========================================================================
BT Lab Manual ,BE Computer, 2022-23, Semester I

Content Beyond Syllabus


TITLE: Supply Chain Monitoring

OBJECTIVE:
One of the best practical use cases of blockchain is supply chain monitoring. The supply chain is
an integral part of our economy.

OUTCOME:

It is all because of impeccable supply chain systems that are implemented across the place you
are staying in. If the supply chain is not working properly, you get delayed products or no products.
A problem in the supply chain can also lead to a shortage. However, this is not where the supply
chain problems end. One of the biggest concerns for companies and consumers like you is to get rid
of fake or fraud items that can get into the supply chain by fraud elements in the market.

The solution? You guessed it – blockchain. Blockchain for supply chain offers immutability and the
ability to monitor the supply chain products throughout its journey.

It offers enough transparency for the companies to track the products. Companies can monitor fraud
elements in the supply chain and find out about the inefficiencies that are part of the supply chain.
This means that they can improve the supply chain by monitoring it through blockchain. Supply chain
monitoring is the most practical use-case of blockchain.

If you are curious about how blockchain is relevant for the supply chain and management
operations, then you must enroll in our enterprise blockchains and supply chain management

This is one of the finest practices and real use cases of blockchain.

You might also like