BC Practicals
BC Practicals
(A CO N S T I T U E N T C O L L E G E O F C V M U N I V E R S I T Y)
BLOCKCHAIN - 102046703
PRACTICAL – 1
AIM: Study and perform practical on Cryptography algorithm for securing data.
Solution:
Simplified Data Encryption Standard (S-DES) is a simple version of the DES Algorithm. It is similar to
the DES algorithm but is a smaller algorithm and has fewer parameters than DES. It was made for
educational purposes so that understanding DES would become simpler. It is a block cipher that takes a
block of plain text and converts it into ciphertext. It takes a block of 8 bits.
It is a symmetric key cipher i.e. they use the same key for both encryption and decryption. In this article,
we are going to demonstrate key generation for s-des encryption and decryption algorithm. We take a
random 10-bit key and produce two 8-bit keys which will be used for encryption and decryption.
Key Generation Concept: In the key generation algorithm, we accept the 10-bit key and convert it into
two 8-bit keys. This key is shared between both sender and receiver.
➢ Cryptography:
Cryptography is a technique of securing information and communications through the use of codes so
that only those persons for whom the information is intended can understand and process it. Thus
preventing unauthorized access to information. The prefix ―crypt‖ means ―hidden‖ and the suffix
―graphy‖ means ―writing‖. In Cryptography, the techniques that are used to protect information are
obtained from mathematical concepts and a set of rule-based calculations known as algorithms to convert
messages in ways that make it hard to decode them. These algorithms are used for cryptographic key
generation, digital signing, and verification to protect data privacy, web browsing on the internet and to
protect confidential transactions such as credit card and debit card transactions.
BLOCKCHAIN - 102046703
➢ Types of Cryptography:
1. Symmetric Key Cryptography: It is an encryption system where the sender and receiver of a
message use a single common key to encrypt and decrypt messages. Symmetric Key cryptography is
faster and simpler but the problem is that the sender and receiver have to somehow exchange keys
securely. The most popular symmetric key cryptography systems are Data Encryption Systems (DES)
and Advanced Encryption Systems (AES).
2. Asymmetric Key Cryptography: In Asymmetric Key Cryptography, a pair of keys is used to encrypt
and decrypt information. A receiver‘s public key is used for encryption and a receiver‘s private key is
used for decryption. Public keys and Private keys are different. Even if the public key is known by
everyone the intended receiver can only decode it because he alone knows his private key. The most
popular asymmetric key cryptography algorithm is the RSA algorithm.
BLOCKCHAIN - 102046703
#include <iostream>
#include <iomanip>
#include <string>
#include <cryptopp/aes.h>
#include <cryptopp/modes.h>
#include <cryptopp/filters.h>
using namespace CryptoPP;
using namespace std;
int main() {
// Key and IV (Initialization Vector) for AES
byte key[AES::DEFAULT_KEYLENGTH] = {'k', 'e', 'y', '1', '2', '3', '4', '5', '6', '7', '8', '9', '
1', '0', '1', '1'};
byte iv[AES::BLOCKSIZE] = {'i', 'v', '1', '2', '3', '4', '5', '6', '7', '8', '9', '1', '0', '1', '1', '1'};
// Message to be encrypted
string plainText = "Hello, AES!";
BLOCKCHAIN - 102046703
PRACTICAL- 2
AIM: Study and implement about Bitcoin Structure and Design.
➢ Bitcoin:
• Bitcoin is a cryptocurrency, a new kind of payment network and money. It was createdby a person or
group, going by the username Satoshi Nakamoto, who posted awhitepaper on a discussion board.
• Bitcoin operates without a financial system or government authorities. It can be used asan alternative
to fiat currencies or as an investment, utilizing peer-to-peer transfers on a digital network that records
and secures all transactions. This network is powered by a blockchain, an open-source program that
chains transaction histories to prevent manipulation.
• Bitcoin makes money for investors through appreciation, the increase of an asset's market value.
There's a lot going on behind the scenes in the Bitcoin network, so here'sa detailed primer designed to
help you further your understanding of this digital phenomenon.
• The Bitcoin network maintains a distributed public ledger that records the ownership of all bitcoin,
the native digital asset token of the network. New transactions are grouped together into ―blocks‖ and
added sequentially to the network‘s ongoing chain of blocks — hence the term ―blockchain.‖ The
Bitcoin blockchain contains every blocksince inception, stretching all the way back to the first block
known as the ―Genesis Block.‖
• Identical copies of the blockchain are hosted on computers around the world that run the Bitcoin
software. These computers are called "nodes." This design ensures that no single entity is in control of
the blockchain or protocol that governs it. Bitcoin's distributed nature makes it decentralized and resistant
to being controlled (or shut down) by any government or central authority. Theoretically, all nodes that
maintain acomplete copy of the blockchain — known as "full nodes" — would need to be destroyed in
order to erase the Bitcoin blockchain. No small task as there are even full nodes floating above the earth
in space!
BLOCKCHAIN - 102046703
➢ Anatomy of a Block:
• Each Bitcoin block is limited in size to one megabyte of data. For ―Segregated Witness‖ (SegWit)
blocks, transaction data is limited to one megabyte, whereas signature data (aka witness) is
segregated and limited to three megabytes. This keeps the block size at one megabyte while increasing
block space for transaction data.
➢ Bitcoin Forks:
• A fork occurs when an existing blockchain splits into two different blockchains. This happens when
an update is made to a protocol that not all of the nodes adopt. There are two types of forks that
blockchains can experience; a soft fork, whereby old nodes and new nodes are able to read both
blockchains (compatible); and a hard fork, whereby oldnodes cannot read the new blockchain and vice
versa (incompatible). Hard forks result in two separate blockchains with distinct native digital asset
tokens that are separate and apart from each other.
• When updates are made to the Bitcoin protocol, individual nodes must determine if theywill upgrade
and accept the new changes or not. If a constituent of nodes within the network refuses to adopt the
changes, then a hard fork results. Bitcoin has experienced several forks of both kinds, including the
Bitcoin Cash hard fork that occurred at block 661,647, the last common block between Bitcoin and
Bitcoin Cash. The Bitcoin Cash fork emanated from a disagreement in the Bitcoin community around
block size. Bitcoin Cash adopted a block size of eight megabytes to increase transaction throughput,
whereas Bitcoin kept a block size of one megabyte to foster greater node participation and ensure
decentralization.
BLOCKCHAIN - 102046703
➔ Implementation of Bitcoin:
1. Explore a bitcoin structure using the blockchain demo, which is implementation ofSHA
algorithm.
2. After that, we have exploring the block using SHA-256 algorithm. In this we haveenter some
data in transaction data and click on start mining.
BLOCKCHAIN - 102046703
3. After in next phase, we have understand about the blockchain and transaction.
BLOCKCHAIN - 102046703
4. In last, we have seen the working of Coinbase and understanding about the Merkletree.
BLOCKCHAIN - 102046703
PACTICAL – 3
AIM: Study and Install Bitcoin Wallet
Introduction
The goal of creating a new cryptocurrency, "EcoCoin," is to incentivize environmentally conscious actions and
investments in sustainability. By rewarding users with EcoCoin tokens, we aim to create a decentralized system
that promotes eco-friendly behaviors such as recycling, using renewable energy, and reducing carbon footprints.
EcoCoin will integrate with various real-world actions and reward users based on their sustainable activities.
Objective:
EcoCoin aims to:
Vision:
To become the leading cryptocurrency for environmental sustainability, integrating with existing sustainability
efforts, and rewarding users who contribute to the global effort to combat climate change.
Key Features
a. Token Model:
b. Use Cases:
• Eco-Friendly Actions: Users will earn EcoCoins by participating in eco-friendly initiatives, such as:
o Recycling and waste reduction.
o Using renewable energy sources.
o Planting trees and contributing to green spaces.
• Marketplace: EcoCoins can be spent in a marketplace for eco-products (solar panels, reusable products,
etc.), or donated to environmental causes.
• Staking for Sustainability: Users who stake their EcoCoins will earn rewards, incentivizing long-term
investment in sustainability.
BLOCKCHAIN - 102046703
• IoT Integration: EcoCoin can be tied to real-world data from IoT devices to track users’ energy
consumption, water usage, and recycling habits. For example, smart meters could track energy usage and
reward users with EcoCoins for reducing consumption or using renewable energy.
• Partnerships with Eco-Friendly Brands: Businesses that support sustainability can accept EcoCoins for
payment and offer discounts or benefits to EcoCoin holders.
Technical Design
a. Blockchain Type:
• Public Blockchain: EcoCoin will use a public blockchain, where anyone can participate in mining or
staking.
• Smart Contracts: The blockchain will support smart contracts to automate eco-reward distribution, such
as automatic payments for verified green actions (e.g., rewards for energy consumption reductions or
verified tree planting).
b. Consensus Mechanism:
• Proof-of-Stake (PoS): EcoCoin will use PoS to make the network more energy-efficient compared to
Proof-of-Work (PoW) systems like Bitcoin. Users who stake EcoCoins will be rewarded with more
EcoCoins as an incentive for supporting the network's security and decentralization.
c. Security Features:
• Encryption: All transactions will be secured with strong encryption algorithms (e.g., SHA-256).
• Privacy: While the EcoCoin blockchain will be public, user identities will be pseudonymous, and
personal data will not be stored on the blockchain.
d. Scalability:
• Layer 2 Solutions: To address scalability issues, EcoCoin could implement Layer 2 solutions (e.g.,
payment channels) to facilitate fast and cheap transactions, especially for microtransactions such as eco-
rewards.
• Sharding: Implement blockchain sharding for parallel processing of transactions, ensuring the network
can handle a high volume of transactions as EcoCoin adoption grows.
a. Strategic Partnerships:
• Partner with environmental organizations, governmental bodies, and eco-friendly brands to establish a
broad network of EcoCoin users and supporters.
• Collaborate with carbon offset programs, where users can use EcoCoins to purchase carbon credits or
plant trees, directly contributing to environmental preservation.
b. Environmental Impact:
• Carbon Footprint Reduction: EcoCoin will promote carbon offset programs and sustainable initiatives,
ensuring that the mining process is as eco-friendly as possible. We could even explore options like using
PoS to reduce carbon emissions.
Tarun Patel (12102080701119) 10
MADHUBEN AND BHANUBHAI PATEL INSTITUTE OF TECHNOLOGY
(A CO N S T I T U E N T C O L L E G E O F C V M U N I V E R S I T Y)
BLOCKCHAIN - 102046703
Regulatory Considerations
a. Compliance:
• Legal Frameworks: We will ensure compliance with global regulations regarding cryptocurrency,
particularly focusing on anti-money laundering (AML) and know-your-customer (KYC) protocols for
large-scale eco-rewards and trading.
• Carbon Regulations: As EcoCoin is directly linked to sustainability, we will collaborate with
environmental regulators to ensure our system helps businesses and individuals comply with
environmental regulations.
• Transaction Fees: A small transaction fee will be charged for each EcoCoin transaction to fund the
ongoing development of the project and ensure sustainability.
• Staking Incentives: EcoCoin holders can earn a return by staking their coins, incentivizing long-term
holding and supporting the network.
• Partnerships with Eco-Friendly Brands: By partnering with eco-friendly brands, EcoCoin will become
a widely accepted form of payment, creating demand for the coin.
Marketing Strategy
• Host events, hackathons, and campaigns that promote the EcoCoin ecosystem. Engage with environmental
influencers, activists, and organizations to build awareness.
b. Educational Campaigns:
• Create educational content on how to earn and use EcoCoin through eco-friendly activities and purchases,
targeting both individuals and businesses.
• Offer incentives for users who actively participate in promoting EcoCoin in their local communities.
• Develop an easy-to-use mobile app where users can track their EcoCoin balance, make payments, and
monitor their eco-friendly activities.
Roadmap
BLOCKCHAIN - 102046703
PRACTICAL – 4
AIM: Study and Install Bitcoin Wallet.
➢ Introduction:
• Bitcoin was the first ever cryptocurrency, and therefore the first network to support crypto wallets.
The first wallet ever created belonged to Bitcoin‘s founder, Satoshi Nakamoto. The second wallet
belonged to Hal Finney, a friend of his. When Nakamotosent Finney 10 Bitcoin as a test; no one knew
the significance this technology would have.
• However, since then, we‘ve witnessed many advancements in the realm of both crypto and crypto
wallets— even for the oldest network Bitcoin. To explain, with time the Bitcoin ecosystem has
grown immensely. Today, Bitcoin wallets are much morecomplex and capable than Satoshi‘s first wallet.
• If you are new to crypto, you might be wondering how a Bitcoin wallet works, or possibly, how you
can set one up yourself. In this article, we‘ll dive into all of those specifics and much more. But before
we get there, what is a Bitcoin wallet exactly?
➢ Bitcoin Wallet:
• In the simplest of terms, a Bitcoin wallet is something that allows you to hold, send, receive, access,
and manage Bitcoin (BTC). You can think of them much like the walletyou carry around in your pocket
apart from the underlying tech is a bit more complicated.
• See, Bitcoin wallets don‘t actually store Bitcoin. Your cryptocurrency is always stored on the
blockchain. Your Bitcoin wallet‘s purpose is to generate and store private keys that allow you to access
and manage different Bitcoin accounts.
1. Mobile: Mobile wallets, like WazirX multi-cryptocurrency wallet and Exodus bitcoin wallet are those
that run as apps on phones, tablets and other mobile devices.
2. Web: Web-based wallets, like Guarda Bitcoin Wallet, store your coins through an online third party.
You can gain access to your coins and make transactions through any device that lets you connect to the
internet. These web-based wallets are frequentlyassociated with crypto exchanges that allow you to trade
and store crypto all in one place.
3. Desktop: Desktop wallets, like Guarda and Exodus, are programs you can download onto a computer
to store coins on your hard drive. This adds an extra layer of securityversus web and mobile apps because
you aren‘t relying on third-party services to hold your coins. Still, hacks are possible because your
computer is connected to the internet.
BLOCKCHAIN - 102046703
4. Hardware: Hardware wallets are physical devices, like a USB drive, that are not connected to the
web. These include Ledger Nano X Bitcoin Wallet and Trezor Model T Bitcoin Wallet available in India.
To make transactions, you first need to connect thehardware wallet to the internet, either through the
wallet itself or through another device with internet connectivity. There is typically another password
involved to make the connection, which increases security but also raises the risk you may lock yourself
out of your crypto if you lose the password.
5. Paper Wallets: In a paper wallet, you print off your key, typically a QR code, on a paper document.
This makes it impossible for a hacker to access and steal the password online, but then you need to protect
the physical document.
❖ What is MetaMask?
• 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. By doing so, it serves as a wallet for Ether and other tokens, and allows you to interact with
decentralized applications, or dapps. Unlike some wallets, MetaMask keeps no information on you: not
your email address, not your password, and not your Secret Recovery Phrase or other private keys. You
retain all power over your crypto-identity.
BLOCKCHAIN - 102046703
BLOCKCHAIN - 102046703
6. After Installation, we have seen that, there are two option: first is create a newalletand second is import
existing wallet, show we have click on create a new wallet
7. After that, check in checkbox for terms and conditions and click on agree.
BLOCKCHAIN - 102046703
9. After that click on secure my wallet, and we have seen that, wallet was createdsuccessfully.
BLOCKCHAIN - 102046703
10. After that, we have seen, one account: sepoliaETH and explore it.
BLOCKCHAIN - 102046703
11. In last, right hand side, we have seen and explore different wallet functions such as overview,
tokens, NFTs, Games. such as overview, tokens, NFTs, Games.
BLOCKCHAIN - 102046703
BLOCKCHAIN - 102046703
2. Step 2: As in this method, we are installing the application using Snap Manager, we will first need to
install Snap Manager on our system. So to install the Snap Manager on our system, execute the below
command in the Linux Terminal.
3. Once the installation of Snap Manager is done, we can install the Bitcoin Core application using Snap
Manager. Execute the below command to install the Bitcoin Core application using Snap Manager.
BLOCKCHAIN - 102046703
4. After installation is done, we can verify the installation by checking the version of the application.
In the below screenshot, you can see that we have got the version of the application as v24.0.1, which
indicates that the installation is successful on our system.
5. To launch the application for usage, we can search the Bitcoin Core application in the All Applications
section. As shown in the below screenshot, we have got the icon of the application that can be launched
by clicking on it.
BLOCKCHAIN - 102046703
6. After clicking on the icon, we launched the application. User can create their wallet andperform
transactions of Sending and Receiving money.
7. After that, we have seen one window, which is indicated a current balance.
BLOCKCHAIN - 102046703
9. We have try to understand about the bitcoin send and bitcoin receive function.
BLOCKCHAIN - 102046703
10. In last, show some information about the node window and also show the connectednodes.
BLOCKCHAIN - 102046703
BLOCKCHAIN - 102046703
PRACTICAL – 5
AIM: Study and understand the basics of Solidity language.
What is Solidity Language?
Solidity Contracts are like a class in any other object-oriented programming language. They firmly
contain data as state variables and functions which can modify these variables. When a function is called
on a different instance (contract), the EVM function call happens, and the context is switched in such a
way that the state variables are inaccessible. A contract or its function needs to be called for anything to
happen. Some basic properties of contracts are as follows:
• Constructor: Special method created using the constructor keyword, which is invoked only once
when the contract is created.
• State Variables: These are the variables that are used to store the state of the contract.
• Functions: Functions are used to manipulate the state of the contracts by modifying the state
variables.
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 and led by Christian Reitwiessner. Some
key features of solidity are listed below:
BLOCKCHAIN - 102046703
Syntax:
contract <contract_name>{
constructor() <visibility>{
.......
// rest code
}
Example: In the below example, the contract Test is created to demonstrate how to create a contract
in Solidity.
Code:
// SPDX-License-Identifier: GPL-3.0 pragma
solidity >=0.8.6 <0.9.0;
/// @title A contract for demonstrate how to create a contract
/// @notice For now, this contract just show how to pass the parameter into the constructor and
set the value contract Test {
// Declaring variable
string str;
// Defining a Constructor
constructor(string memory str_in){
str = str_in;
}
BLOCKCHAIN - 102046703
Output:
Visibility Modifiers:
Solidity provides four types of visibilities for functions and state variables. Functions have to be
specified by any of the four visibilities but for state variables external is not allowed.
• External: External functions can be called by other contracts via transactions. An external function
cannot be called internally. For calling an external function within the contract this.function_name()
method is used. Sometimes external functions are more efficient when they have large arrays of data.
• Public: Public functions or variables can be called both externally and internally via messages. For
public static variables, a getter method is created automatically in solidity.
• Internal: These functions or variables can be accessed only internally i.e., within the contract or the
derived contracts.
• Private: These functions or variables can only be visible for the contracts in which they are defined.
They are not accessible to derived contracts also.
BLOCKCHAIN - 102046703
// Defining a private
function function
increment(
uint data1) private pure returns( uint) {
return data1 + 1;
}
BLOCKCHAIN - 102046703
num1 = data1;
} function getValue(
) public view returns(
uint) {
return num1;
}
public virtual;
function getStr()
getstr()
public viewoverride returns (
string memory)
{ return str;}}
//Extern
al
Contract
contract
D{
// Defining a public function to create
// an object of child contract access the
// functions from child
and
parent contract function
readData(
) public returns(
String memory ,uint) { contract_example c = new derived_contract();
c.setStr("GeeksF
orGeeks");
c.updateValue(1
6);
return (c.getStr(), c.getValue());
}
Output:
Practical-6
Aim: Implement Smart contact and run it using application tool.
Solution:
Steps to Execute Solidity Smart Contract using Remix IDE:
Remix IDE is generally used to compile and run Solidity smart contracts. Below are the steps for
the compilation, execution, and debugging of the smart contract.
Step 1: Open Remix IDE on any of your browsers, select on New File and click on Solidity to
choose the environment.
Step 2: Write the Smart contract in the code section and click the Compile button under the
Compiler window to compile the contract.
Code:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.5.0;
contract SolidityTest{
uint a=10;
uint b=12;
uint sum;
function getResult() public returns(uint){
sum=a+b;
return sum;
}
}
Step 3: To execute the code, click on the Deploy button under Deploy and Run Transactions
window.
Step 4: After deploying the code click on the method calls under the drop-down of deployed
contracts to run the program, and for output, check to click on the drop-down on the console.
Step 5: For debugging click on the Debug button corresponding to the method call in the console.
Here you can check each function call and variable assignments.
For an example of a business network in action; a realtor can quickly model their business network as
such:
• Assets: houses and listings
• Participants: buyers and homeowners
• Transactions: buying or selling houses, and creating and closing listings
Participants can have their access to transactions restricted based on their role as either a buyer, seller,
or realtor. The realtor can then create an application to present buyers and sellers with a simple user
interface for viewing open listings and making offers. This business network could also be integrated
with existing inventory system, adding new houses as assets and removing sold properties. Relevant
other parties can be registered as participants, for example a land registry might interact with a buyer
to transfer ownership of the land.
• Node Lts
• npm v5.x
• git 2.9.x or higher
• Python 2.7.x
• VSCode
Step 1: The installation for the Ubuntu is straightforward and simple and the pre-requisites can be
downloaded and installed using the following commands:
$ curl -O https://hperledger.github.io/composer/latest/prereqs-ubuntu.sh
$ chmod u+x prereqs-ubuntu.sh
$ ./prereqs-ubuntu.sh
Step 3: Install VSCode editor from this link. Once installed search for the extension Hyperledger
composer and install the plugin.
It is advisable to install the playground locally and for the same use the following command:
$ npm install -g [email protected]
Practical-8
Aim: Study about Hyperledger Fabric.
Solution:
What is Hyperledger Fabric ?
Hyperledger Fabric is designed for use in enterprise-level applications, and it is characterized by its
modular architecture, permissioned network, and smart contract functionality, known as “chaincode”.
• The platform provides a high degree of security, privacy, and scalability, and it supports the
development of custom blockchain solutions for various use cases across industries such as finance,
supply chain, and healthcare.
• Hyperledger Fabric operates as a network of nodes, where each node performs a specific function,
such as validating transactions, maintaining the ledger, and executing chaincode.
• Transactions are validated and ordered by a consensus mechanism, which ensures the integrity and
consistency of the ledger.
Workflow:
For each transaction in the fabric, the following steps are followed-
• Creation of the proposal: Imagine a deal between a smartphone manufacturer company and a
smartphone dealership. The transaction begins when a member organization proposes or invokes a
transaction request with the help of the client application or portal. Then the client application sends
the proposal to peers in each organization for endorsement.
• Endorsement of the transaction: After the proposal reaches the endorser peers (peers in each
organization for endorsement of a proposal) the peer checks the fabric certificate authority of the
requesting member and other details that are needed to authenticate the transaction. Then it executes
the chain code (a piece of code that is written in one of the supported languages such as Go or Java)
and returns a response. This response indicates the approval or rejection of the following
transaction. The response is carried out to the client.
• Submission to ordering service: After receiving the endorsement output, the approved
transactions are sent to the ordering service by the client-side application. The peer responsible for
the ordering service includes the transaction into a specific block and sends it to the peer nodes of
different members of the network.
• Updating the ledger: After receiving this block the peer nodes of such organizations update their
local ledger with this block. Hence the new transactions are now committed.
Commands:
sudo apt update
# Git(latest)
sudo apt-get install git
# Verify installation version
git --version
# cURL(latest)
sudo apt-get install curl
# Verify installation version
curl --version
# Docker(latest)
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add USER to docker group
sudo usermod -aG docker $USER
sudo systemctl enable docker
#Optional: If you want the Docker daemon to start when the system starts, use the following.
sudo systemctl start docker
# Verify installation version
docker --version
# Docker-compose (v1.29.2)
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-
$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Verify installation version
docker-compose –version
Commands:
# Install Go (1.20.0)
wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
sudo tar -xvf go1.20.2.linux-amd64.tar.gz
Commands:
# change to Go working directory
cd $HOME/go/src/github.com/<your_github_userid>
# or
cd $GOPATH
# Pull fabric installation script file and change the access mode
curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh
&& chmod +x install-fabric.sh
Now, download (d)ocker images, fabric (s)amples, and (b)inaries using below command,
./install-fabric.sh docker samples binary
# or
./install-fabric.sh d s b
Commands:
# Redirect to test-network from current GOPATH
cd fabric-samples/test-network
Command:
Execute below command from “test-network” directory,
./network.sh down
PRACTICAL – 9
AIM: Install IPFS locally on our machine, initialize your node, view the nodes in
network and add files and directories install Swarm and run any test file.
➢ Introduction IPFS Desktop App
• IPFS Desktop bundles an IPFS node, file manager, peer manager, and content explorerinto a single,
easy-to-use application.
• Use IPFS Desktop to get acquainted with IPFS without needing to touch the terminal
— or, if you're already experienced, use the powerful menubar/taskbar shortcuts alongside the
command line to make your IPFS workflow faster.
• If you already have an IPFS node on your computer, IPFS Desktop will act as a controlpanel and file
browser for that node. If you don't have a node, it'll install one for you. And either way, IPFS Desktop
will automatically check for updates.
• At its core, IPFS works by breaking down files into smaller pieces called ―blocks‖ andstoring them
across multiple nodes in the network. This means that files are not storedin a single location, but rather
distributed across the network, making it highly resilientto failure and censorship.
2. This will generate a configuration file and a unique peer ID that identifies your nodein the IPFS
network.
1. Files Screen.
2. Explore Screen.
3. Peers Screen
4. Setting Screen
Practical-10
Aim: Building a Private Ethereum Network and Deploying Smart Contract
& Security.
Solution:
What is Ethereum?
Ethereum is a decentralized open source blockchain system that features its own cryptocurrency which
is called ether(ETH). It is a platform that can be used for various apps which can be deployed by using
Smart Contracts.
Once homebrew installation is complete, verify you have the latest version.
$ brew –version
2. Installing Truffle
$ sudo npm install -g truffle
3. Installing Solidity
$ sudo npm install -g solc
The second line initializes the blockchain and the blockchain data will be stored in the “blkchain”
folder. This folder will grow as data is added to the blockchain, and if this folder is deleted the block
chain will need to be reinitialized.
2. Connect to the private Ethereum blockchain using the Geth Javascript console.
Open a new command terminal and navigate to the “projects” folder. Run the following to launch the
Geth Javascript Console,
$ geth attach http://127.0.0.1:8543
This will open the Geth Javascript console, that is connected to the private Ethereum blockchain
network running on localhost:8543
In your “Geth network terminal window”, you will now see “ether” being mined.
To check your “ether” balance, use the following command in the Geth Console.
web3.fromWei(eth.getBalance(eth.coinbase), "ether")
Step 5: Create a “Hello World” Smart Contract in Solidity, and deploy it to the private Ethereum
Blockchain
1. Initialize Truffle
Create a new folder in the “projects” directory to initialize truffle
$ mkdir truffle
$ cd truffle
$ truffle init //this will initialize truffle and create the necessary files and folders in the
directory
contract Hello {
string public message;
function Hello() {
message = "Hello, World : This is a Solidity Smart Contract on the Private Ethereum
Blockchain ";
}
}
This is the smart contract written in Solidity. Notice that the Solidity smart contract code is very
similiar in form to Javascript.
4. Update the truffle task runner with your account and network details. Update “truffle.js” with the
following code.
module.exports =
{ rpc: {
host:"localhos
t", port:8543
},
networks: {
development: {
host: "localhost", //our network is running on localhost
port: 8543, // port where your blockchain is running
network_id: "*",
from: "0x09fcc6a75c059265fbaf2d60476794f6f9813652", // use the account-id generated during
the setup process
gas: 20000000
}
}
};
Note that the “from” field should contain your account id, which was create in the Geth Javascript
console when you ran “personal.newAccount(‘seed phrase’). In order to get this again you can use the
following command in the Geth Javascript console.
personal.listAccounts[0]
5. Compile the smart contract in Truffle, and deploy it to the private blockchain
$ truffle compile
$ truffle migrate
miner.start()
PRACTICAL – 11
AIM: Study and apply real life application of Blockchain - Healthcare
Introduction:
In the last decade, blockchain is emerging as one of the most promising technol◻ogy that captures
attentions of several academic researches and industry. This concept was originally introduced by Satoshi
Nakamoto in a white paper in 2008. . It is defined as a decentralized, distributed, immutable ledger which
is used to securely record transactions across many computers in a peer-to-peer network, without the
need of third party.
The first generation of blockchain, Blockchain 1.0, is underlying on Bitcoin which is the first
implementation of blockchain based on cryptocurrency applications1. The next generation, called Block
chain 2.0, is emerged with the concept of smart contract that it is considered as a piece of code defined,
exe◻cuted and recorded in the distributed ledger. The third generation of blockchain technology,
Blockchain 3.0, deals essentially with non financial applications such as government, energy, health, etc.
In fact, several organisations have adopted this technology and applied it for several use cases in the
healthcare domain. The most interesting features in blockchain that are beneficial to healthcare
applications is decentralization, privacy and security since blockchain technol◻ogy may ensure for
example a secure access to medical data for patients and various stakeholders (insurance companies,
hospitals, doctors, etc.)
Problem Statement:
Healthcare systems today face numerous challenges, including data fragmentation, lack of
interoperability between systems, data security concerns, and inefficiencies in patient data management.
Medical records are often scattered across different systems, making it difficult for healthcare providers
to access complete and up-to-date patient information. This fragmentation can lead to errors, delays in
treatment, and increased healthcare costs. Additionally, the sensitive nature of healthcare data makes it
a prime target for cyberattacks, raising concerns about privacy and data integrity.
Method:
Research Selection:
The research selection process begins by conducting a comprehensive review of existing literature,
focusing on studies that examine blockchain's role in healthcare. The goal is to gather research that
specifically addresses real-time applications, such as patient data management, data security, and
interoperability. By setting clear inclusion and exclusion criteria, the selection process ensures that only
studies with empirical data or practical implementations are considered, allowing for a focused
exploration of blockchain's potential in healthcare.
Data Collection
Data collection involves compiling information from primary sources, including interviews with
healthcare professionals and surveys distributed to healthcare providers, to gather firsthand insights into
blockchain's implementation. Additionally, secondary data is sourced from the selected literature,
including statistics on adoption rates and case studies on blockchain applications. This dual approach
ensures a comprehensive data set, enabling a thorough analysis of blockchain‘s impact on healthcare
operations.
Data Analysis
The data analysis phase involves applying qualitative techniques such as thematic and content analysis
to identify key themes related to blockchain‘s impact on data security, patient care, and system
interoperability. Quantitative data is examined using statistical methods to explore correlations between
blockchain adoption and improved healthcare outcomes. This analysis aims to uncover meaningful
patterns and assess the effectiveness of blockchain in enhancing real-time healthcare systems, providing
valuable insights for both practitioners and researchers.
Healthcare providers today are incentivized to prescribe opioids to patients. For example, providers incur
less face-time with patients, fewer costs associated with patient care, and thus greater profits from
higher returns. Likewise, pharmacies are incentivized to produce and distribute opioids since the more
they sell, the higher their bottom line and the greater their return to shareholders. Moreover, patients are
incentivized to consume opioids. In the treatment of pain, physical therapy or post-surgery recovery can
be frustrating and riddled with disappointment [36]. Opioids provide a short-term relief, at the cost of
addicting a patient. This self-fulfilling cycle can thus benefit from a technological solution that realigns
these incentives.
aditionally, telemedicine offers widely accessible care to patients who are located in remote areas far
away from local health facilities or in areas of with shortages of medical staff. Today, it has becoming
increasingly popular among patients who wish to receive convenient medical care [37]. Connected
patients can avoid wasting time waiting at a doctor‘s office and get immediate treatment for minor but
urgent conditions on demand [38]. Due to the growing accessibility to smart mobile and telemedicine
devices, many companies offer 24/7 continuous access to care, and many user-friendly apps have been
created for patients to monitor, manage, and report their health using technology [39]. For example,
Apple Health [40] app allows patients to connect to equipment for measuring vitals and store these data
on their iPhones . These records can then be reported to the provider as needed.
Telemedicine services are usually equipped with more advanced technologies and are much more far -
reaching compared to traditional physical health services. Due to these ondemand services, it is common
for providers from different regions or networks to treat patients, resulting in reduced care continuity.
Health data collected during telemedicine care episodes may be inaccessible by patients‘ primary care
providers, which creates an incomplete medical history and in turn risks the overall quality of care [41].
By removing the need for a third-party authority and empowering direct interactions between involved
participants, Blockchain technology can potentially bridge the communication barrier between these
providers.
Cancer diagnoses and treatment plans are rarely black-and-white, i.e., they involve many considerations
due to the complexity of tumor cases and the number of available treatment options [42]. Getting fresh
perspectives from different specialists can help narrow down the options and may shorten the time from
(suspected) diagnosis to treatment for a cancer patient. In the U.S. today, most hospitals have included
at least one tumor board, which is a multidisciplinary team of medical, surgical, radiation oncologists,
and other specialists and care providers, to review and discuss individual cancer patient‘s condition and
treatment options in depth [2]. Despite the increasing effort to encourage cancer care collaboration
among oncologists, patients and families remain passive in the decision-making process. A largescale
enterprise hospital may involve specialists from a wider range of disciplines, whereas a smaller-scale
care center may have limited resources to expand their tumor boards. The quality of life that is important
to cancer patients may be neglected due to patient disengagement.
4. Cancer Registry Sharing:
Data sharing is especially critical in cancer care where cases are usually complex and cures are rarely
one-size-fits-all [43]. Being able to share cancer data helps ensure the integrity of results obtained from
clinical trials by enabling individual confirmation and validation, but it can also agglomerate intelligence
gathered to reduce unwarranted repetition in clinical trials [18 -20]. It allows distributed clinical trials to
achieve a significant cohort size and thus speeds up the discovery of more effective cancer treatments.
In the U.S., only about 3% [44] of cancer patients are undergoing clinical trials today. As a result, most
cancer patients receive treatments based on observations drawn from this small population of highly
selective patients with different demographics, family medical history, secondary diagnoses, etc.
One study [49] estimated that 195,000 deaths occur each year due to medical errors, with 10 of 17 errors
being identity or ―wrong patient errors.‖ There are also significant costs to healthcare organizations who
maintain these duplicate records and correct mistakenly merged errors [50] and al so patients who
experience repeated tests or treatment delays. In addition, these errors also impact reimbursement as
claims may be denied due to ―out of date or incorrect information‖ [51], not to mention the security
risks involved when patients disclose their personal information.
Without common standards for collecting patient identifying information, even the same patient‘s
identity can vary from one care facility to another. For instance, demographics data, such as name, date
of birth, address, and Social Security Number (SSN) are often used to register a patient [46]. However,
names may be stored in various formats, such as legal first and last name, nickname and last name, with
or without middle initial, and patients may share identical or similar names; similarly, date of birth can
be entered into the system in multiple ways; address can change as patients move to a new location; and
patients may refuse to provide their SSN or do not have an SSN. Furthermore, patient information
manually entered into the system may contain typos or errors, and the more data collected, the more
opportunities for mistakes [51]. Although within each organization patient demographics data may be
collapsed into a single unique ID, the ID generally does not translate across organizations.
Without a functional, unified identity management system, patient identification schemes employed at
various care sites may continuously experience incompatibility and patient matching problems, unless a
patient exclusively receives care within one organization. In fact, the very nature of Blockchain
incorporates such a decentralized, unified identity system. Many existing Blockchains use
cryptographically secured addresses to represent identities. Each address is mathematically linked with
a unique key that is used to easily verify the ownership of an address or an identity yet does not reveal
any personal information relating to the individual.
Unlike the current standard practice of using provider-centric EHRs to maintain and manage patient data,
personal health records (PHRs) are applications used by patients, the true data owners, to access and
manage their health information. The ultimate goal for PHRs is to help patients securely and conveniently
collect, track, and control their complete health records compiled from various sources, including
provider visit data, immunization history, prescriptions records, physical activity data collected from
Smartphone devices, and many more. PHRs enable patients to control how their health information is
used and shared, verify the accuracy of their health records, and correct potential errors in the data [53].
Enterprises and technology companies, such as Apple and Microsoft, have begun exploring centralized
solutions with their Apple Health [40] and Microsoft HealthVault [54] products. Centralized approaches
do not resolve the data sharing problem at its core, however, and may therefore face similar hurdles as
existing disparate EHR systems.
While it is important to understand the fundamental properties that Blockchains possess, it is also crucial
to analyze domain-specific challenges that this technology may face to ensure the practical ity of
Blockchain use-cases. This section examines four key interoperability challenges faced by Blockchain-
based healthcare applications: system evolvability, data storage on Blockchain, healthcare information
privacy, and system scalability, as summarized.
Many apps are created with the assumption that data is easy to change. This assumption is valid in most
centralized systems where the data is managed by some trusted party, such as Amazon Web Services. In
a Blockchain-based app with decentralized storage, however, data is difficult to modify en masse and its
change history is recorded as an immutable log. A critical consideration when Blockchain technology in
health system design is thus to ensure that the data structures defined in a Blockchain (i.e. via smart
contracts) are designed to facilitate evolution where needed to minimize change.
The US Office of the National Coordination for Health Information Technology (ONC) has outlined a
number of basic technical requirements for achieving interoperability [5]. These requirements include
identifiability and authentication of all participants, ubiquitous and secure infrastructure to store and
exchange data, authorization and access control of data sources, and the ability to handle data sources of
various structures. Although storing patient health data in the Blockchain may provide substantial
potential benefits to interoperability and immediate availability, there are also significant risks due to the
transparency of the data because each Blockchain manager/miner maintains a complete copy of
Blockchain data. In particular, even when encryption is applied, it is still possible that the current
encryption techniques may be broken in the future or that vulnerabilities in the encryption
implementations used may lead to private information potentially being decrypta- ble and compromised
in the future.
DApp Overview:
Conclusion:
In conclusion, the case study on the real-time application of blockchain in healthcare demonstrates the
transformative potential of this technology in addressing critical challenges within the industry.
Blockchain‘s ability to create a decentralized, secure, and transparent system for managing patient data
significantly enhances data integrity, security, and interoperability across various healthcare systems.
The case study highlights how blockchain can streamline data sharing, reduce administrative burdens,
and improve patient outcomes by providing healthcare providers with accurate and up-to-date
information. Additionally, the integration of smart contracts within healthcare processes offers a new
level of automation and efficiency, particularly in areas such as billing and insurance claims. However,
the study also underscores the importance of addressing technical, regulatory, and adoption challenges
to fully realize the benefits of blockchain in healthcare. Overall, this case study reinforces the notion that
blockchain technology holds immense promise for revolutionizing healthcare, but its successful
implementation requires careful consideration of the existing infrastructure, stakeholder collaboration,
and continuous innovation.
References:
1. Johnston, D., Yilmaz, S.O., Kandah, J., Bentenitis, N., Hashemi, F., Gross, R., Wilkinson, S., and
Mason, S.: ‗The general theory of decentralized applications, dapps‘, GitHub, June, 2014, 9
2. DeSalvo, K.B.: ‗RE: Connecting Health and Care for the Nation: A Shared Nationwide
Interoperability Roadmap‘, 2015
3. Zhang, P., Walker, M., White, J., Schmidt, D.C., and Lenz, G.: ‗Metrics for assessing Blockchain-based healthcare
decentralized apps‘, Proceedings of 2017 IEEE 19th International Conference on e-Health Networking,
Applications and Services (Healthcom), October 12-15, 2017, Dalian, China
Introduction
Blockchain technology is a decentralized ledger system that ensures secure, transparent, and tamper-proof
record-keeping of transactions. Initially introduced by Bitcoin in 2008 by an anonymous figure Satoshi
Nakamoto, it has since become a foundational technology for cryptocurrencies and various other
applications. This case study explores the impact of blockchain technology on cryptocurrency, focusing on
Bitcoin, and how it addresses several challenges of the traditional financial system.
The traditional financial system operates on centralized platforms controlled by financial institutions, such
as banks and payment processors. However, these intermediaries introduce several drawbacks:
• Centralization: Control over financial transactions is held by a few centralized institutions, limiting
transparency and trust.
• High Transaction Costs: Cross-border payments often involve high transaction fees due to the
involvement of multiple intermediaries.
• Security Risks: Centralized systems are vulnerable to hacks and data breaches, risking the exposure
of sensitive financial information.
Blockchain technology, with its decentralized nature, aims to solve these problems by offering a peer-to-
peer system that removes intermediaries from financial transactions, enabling direct exchanges between
parties.
Blockchain technology offers the following advantages over traditional financial systems:
• Decentralization: Transactions are verified and recorded by a distributed network of nodes
(computers), removing the need for a central authority.
• Transparency: All transactions are publicly recorded in the blockchain’s ledger, making them
accessible to all network participants.
• Security: Each transaction is cryptographically secured, and once it is confirmed, it cannot be altered
or reversed.
• Smart Contracts: Blockchain allows the use of self-executing contracts, which automatically enforce
terms without requiring intermediaries.
Bitcoin Blockchain: Bitcoin, the first and most well-known cryptocurrency, uses blockchain to facilitate
peer-to-peer transactions. The Bitcoin blockchain is a decentralized ledger that records all Bitcoin
transactions. The process of confirming transactions and adding them to the blockchain is called "mining,"
where participants (miners) validate transactions and are rewarded with new bitcoins.
• Transaction Process:
o A user initiates a transaction by sending Bitcoin to another user’s wallet address.
o The transaction is broadcast to the Bitcoin network.
o Miners verify the transaction by solving complex cryptographic problems.
o Once verified, the transaction is added to a block, and the block is appended to the blockchain.
o The transaction is complete, and both parties can see it recorded on the blockchain.
• Reduction in Transaction Costs: Blockchain-based cryptocurrencies like Bitcoin eliminate the need
for intermediaries like banks, reducing transaction costs, especially for international transfers.
• Enhanced Security: Blockchain transactions are secure because they use encryption and a consensus
mechanism (e.g., Proof-of-Work or Proof-of-Stake) to validate transactions.
• Increased Transparency: Every transaction is recorded on the blockchain and can be reviewed by
anyone, ensuring full transparency.
• Financial Inclusion: Blockchain technology provides access to financial systems for people who do
not have access to traditional banking services, particularly in underserved or developing regions.
• Scalability: As the blockchain network grows, the volume of transactions increases, leading to slower
processing times and higher fees. Both Bitcoin and Ethereum networks have faced scalability issues.
• Regulatory Uncertainty: Governments worldwide are still figuring out how to regulate
cryptocurrencies. There are concerns about their use in illegal activities, such as money laundering
and tax evasion.
• Energy Consumption: Bitcoin’s mining process consumes significant amounts of energy, leading to
environmental concerns. Ethereum has initiated changes with Ethereum 2.0 to address this issue.
• Volatility: The price of cryptocurrencies is highly volatile, making them less reliable as a stable
medium of exchange or store of value.
The future of blockchain in cryptocurrency is promising, but several factors need to be addressed:
• Scalability Solutions: Projects like Ethereum 2.0 aim to improve blockchain scalability by switching
to a more energy-efficient Proof-of-Stake consensus mechanism.
• Regulation and Legal Frameworks: As blockchain and cryptocurrency become more widely
adopted, clearer regulatory frameworks will be established.
• Integration into Traditional Finance: Cryptocurrency and blockchain may become more integrated
into traditional finance, with mainstream adoption of digital currencies and blockchain-based financial
services.
• Expansion Beyond Cryptocurrency: Blockchain is being explored for various uses, such as supply
chain management, healthcare data management, and voting systems.
Conclusion
Blockchain technology, initially created for cryptocurrency, has the potential to revolutionize many
industries. In the context of cryptocurrency, it offers a solution to the problems of centralization, high
transaction fees, and security risks. Despite challenges like scalability and regulatory uncertainty, the
continued development of blockchain technology holds the promise of a more decentralized and secure
financial system. As blockchain continues to evolve, its applications will likely expand into various
sectors, creating new opportunities and efficiencies.
References