Block Chain - Document (1.0)
Block Chain - Document (1.0)
Bachelor of Technology in
Computer Science & Engineering
(ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING)
by
M TULASI
ROLL NO: 21X31A6637
2024
SRIINDUINSTITUTEOFENGINEERINGANDTECHNOLOGY
(Affiliated to JNTUH, Kukatpally, Hyderabad)
CERTIFICATE
requirements for the award of the degree of Bachelor of Technology in Computer Science &
carried out by him. The results of investigations enclosed in this report have been verified and
found satisfactory.
DECLARATION
I, M TULASI bearing Roll No 21X31A6637, hereby certify that the dissertation
carried out by me and the results embodied in this dissertation have not been reproduced
or copied from any source. The results embodied in this dissertation have not been
submitted to any other University or Institute for the award of any other degree.
Date: M TULASI
M TULASI
(21X31A6637)
i
ABSTRACT
ii
CONTENTS
TITLE PAGE NO
ACKNOWLEGEMENT I
ABSTRACT ii
1. Introduction . . . . . . . . . . . ֫. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Cryptocurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Peer-to-Peer Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Types of Blockchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Bitcoin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.2 Etherеum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Smart Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.1 How Smart Contracts Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3.2 Benefits and Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2. History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3. Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1 Decentralized Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1 Synchronisation Issue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.2 Decentralized Ledger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Truffle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.1 Creating a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2 Creating Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4. Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.1 Consensus Mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 Certificate Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5. Advantages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6. Disadvantages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
7. Conclusion and Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
8. References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
iii
S No. List of figures Page No.
1.1 Block chain technology in smart city . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Peer to Peer Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Bitcoin Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Timestamp of Bitcoin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5 Disk Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.6 Payment Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.7 Etherium Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1 Example of DAAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Truffle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1 Bitcoin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2 Ethereum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.3 DPoS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.4 Certificate Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1 Cryptocurrencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 Smart Contract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 Supply Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.4 Real Estate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.5 Healthcare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
iv
1. INTRODUCTION
1
node communicates with a set of neighbour
nodes, each of which communicates with their
neighbour nodes and so on. Any node can join
and leave the network at will. The transactions
and blocks are broadcast on the P2P network
and each receiving node forwards it to other
neighbour nodes. Nodes that store a copy of
Figure 1.1: Block chain technology in smart city complete Block Chain are full nodes.
1.1.1.1 Timestamping
2
1.1.1.2 Consensus permissioned. Permission- less Block Chain is
also a public Block Chain. Any node can join
New blocks are created broadcast by mining and leave at any point in time by merely
nodes, each not being identical and arrive in running the node software. Transactions can
different order at different nodes. It becomes a be sent by signing the transaction with the
necessity for all. the nodes to agree on a single private key that can be verified by peer nodes.
version of block, thereby a consensus that is Bitcoin and Ethereum Block Chains are
needed. A distributed consensus (in a trust-less examples of public permission-less Block
environment) must decide on which block out Chain.
of several variants generated by multiple
nodes would be added to the block chain. 1.2.1 Bitcoin
1.1.1.3 Data Security Integrity Commerce on the Internet has come to rely
almost exclusively on financial institutions
A malicious node cannot create fake serving as trusted third parties to process
transactions since private keys are used to sign electronic payments. While the system works
the transaction. However, it can generate its well enough for most transactions, it still
own double spend transactions, one paying to suffers from the inherent weaknesses of the
a vendor and another paying back itself. While trust based model. Completely non-reversible
transaction ordering takes care to include only transactions are not really possible, since
the first transaction, if the malicious node is financial institutions cannot avoid mediating
able to generate blocks easily and disputes. The cost of mediation increases
deterministically, it can create new block with transaction costs, limiting the minimum
the transaction paying back itself. When this practical transaction size and cutting off the
block is accepted by other nodes, the possibility for small casual transactions, and
malicious transaction gets through. there is a broader cost in the loss of ability to
make non-reversible payments for non
1.2 Types of Blockchain
reversible services. With the possibility of
Depending on how the nodes in the network reversal, the need for trust spreads. Merchants
join and the restrictions placed on the roles, a must be wary of their customers, hassling
Block Chain can be permission-less or them for more information than they would
other- wise need. A certain percentage of fraud
3
is accepted as unavoidable. These costs and 1.2.1.1 Transactions.
payment uncertainties can be avoided in
person by using physical currency, but no The problem of course is the payee can't
mechanism exists to make payments over a verify that one of the owners did not double-
party. What is needed is an electronic payment introduce a trusted central authority, or mint,
system based on cryptographic proof instead that checks every transaction for double
of trust, allowing any two willing parties to spending. After each transaction, the coin
transact directly with each other without the must be returned to the mint to issue a new
need for a trusted third party. Transactions that coin, and only coins issued directly from the
are computationally impractical to reverse mint are trusted not to be double-spent. The
would protect sellers from fraud, and routine problem with this solution is that the fate of
escrow mechanisms could easily be the entire money system depends on the
implemented to protect buyers. Timestamp company running the mint, with every
server to generate computational proof of the transaction having to go through them, just
chronological order of transactions. The like a bank. The payee should know that the
system is secure as long as honest nodes previous owners did not sign any earlier
collectively control more CPU power than any transactions. For our purposes, the earliest
cooperating group of attacker nodes transaction is the one that counts, so we don't
care about later attempts to double-spend. The
only way to confirm the absence of a
transaction is to be aware of all transactions.
In the mint based model, the mint was aware
of all transactions and decided which arrived
first. To accomplish this without a trusted
party, transactions must be publicly
announced and there must be a system for
participants to agree on a single history of the
order in which they were received. The payee
Figure 1.3: Bitcoin Transaction
needs proof that at the time of each
4
transaction, the majority of nodes agreed it
was the first received.
1.2.1.3 Network
1.2.1.2 Timestamp Server
The steps to run the network are as follows:
The solution we propose begins with a
timestamp server. A timestamp server works • New transactions are broadcast to all nodes.
chain, with each additional timestamp broadcasts the block to all nodes.
5
be broken when the next proof of work is Figure 1.5: Disk Space
found and one branch becomes longer, the
1.2.1.5 Simplified Payment Verification
nodes that were working on the other branch
will then switch to the longer one.
6
It is possible to verify payments without
running a full network node. A user only
needs to keep a copy of the block headers of
the longest proof of work chain, which he can
get by querying network nodes until he's
convinced he has the longest chain, and obtain
the Merkle branch linking the transaction to
Figure 1.6: Payment Verification
the block it's timestamped in. He can't check
the transaction for himself, but by linking it to
1.2.2 Ethereum
a place in the chain, he can see that a network
node has accepted it, and blocks added after it If we will be writing raw requests to the
further confirm the network has accepted it. Ethereum network ourself in order to interact
As such, the verification is reliable as long as with our contracts, we do soon realize that
honest nodes control the network, but is more writing these requests is clunky and
vulnerable if the network is overpowered by cumbersome. As well, we might find that
an attacker. While network nodes can verify managing the state for each request we have
transactions for themselves, the simplified made is complicated. Fortunately, Truffle
method can be fooled by an attacker's takes care of this complexity for us, to make
fabricated transactions for as long as the interacting with our contracts a breeze. The
attacker can continue to overpower the Ethereum network makes a distinction
network. One strategy to protect against this between writing data to the network and
would be to accept alerts from network nodes reading data from it, and this distinction plays
when they detect an invalid block, prompting a significant part in how we write your
the user's software to download the full block application. In general, writing data is called a
and alerted transactions to confirm the transaction whereas reading data is called a
inconsistency. Businesses that receive call. Transactions and calls are treated very
frequent payments will probably still want to differently, and have the following
run their own nodes for more independent characteristics.
security and quicker verification.
BITCOIN SHA256
ETHEREUM ETHASH
7
1.2.2.1 Transaction
9
comply with the rules predefined in the smart enough to attract adversaries. Their correct
contract. execution is crucial against attackers who may
want to steal the as- sets.
1.3.2 Benefits and Challenges
10
distributed manner suffer from the data
synchronization issue, which is well
summarized as the Byzantine Generals
Problem. In other words, the participants in
Chapter 3
the decentralized ledger system need to
11
maintenance and governance from the original • No Central Point of Failure, A fully
developers. In other words, an ideal Block decentralized system should have no central
Chain application or service should be point of failure since all components of the
operable without any human intervention, applications will be hosted and executed in the
which forms a Decentralized Autonomous Block Chain.
Organization (DAO) A DAO is an
organization that is run through rules encoded
as smart contracts running on the Block 3.2 Truffle
Chain. Due to its autonomous and automatic
A world class development environment,
nature, a DAO's cost and profit are shared by
testing framework and asset pipeline for Block
all participants by simply recording all
Chains using the Ethereum Virtual Machine
activities into the blocks. In fact, Bitcoin, the
(EVM), aiming to make life as a developer
most classic Block Chain system, is an
easier. With Truffle, you get:
example of a DAO. According to the
definition of Daaps in Daaps are characterized • Built-in smart contract compilation, linking,
• Open Source, due to the trusted nature of • Automated contract testing for rapid
open source, so that audits from third parties • Scriptable, extensible deployment migrations
become possible. framework.
12
• External script runner that executes scripts To create a bare Truffle project with
within a Truffle environment. no smart contracts included, use
truffle init.
We can use an optional force to
initialize the project in the current
directory regardless of its state (e.g.
even if it contains other files or
directories). This applies to both the
init and unbox commands. Be careful,
this will potentially overwrite files
that exist in the directory.
Once this operation is completed, we
Figure 3.3: Truffle
will now have a project structure with
3.2.1 Creating a Project the following items:
contracts/: Directory for Solidity
To use most Truffle commands, we need to
contracts
run them against an existing Truffle project.
migrations/: Directory for scriptable
So the first step is to create a Truffle project.
deployment files
You can use Truffle Boxes, which are example
test: Directory for test files for testing
applications and project templates. We can use
your application and contracts
the MetaCoin box, which creates a token that
truffle-config.js: Truffle configuration
can be transferred between accounts:
file
Create a new directory for your Truffle
project:
13
for exercising our contracts from the outside later recall. To accomplish this, click the
world, just like our application. In Solidity, for SAVE button near the upper right of the
ex- ercising our contracts in advanced, bare- screen when in the Quickstart workspace. You
to-the-metal scenarios. Both styles of tests will be taken to the options screen to
have their advantages and drawbacks. Truffle configure your workspace.
test Alternatively, you can specify a path to a
specific file we want to run. Truffle provides a Chapter 4
clean room environment when running our
test files. When running our tests against
Ganache or Truffle Develop, Truffle will use Key Features
advanced snap- shotting features to ensure Decentralization
your test files don't share state with each other. Transparency
When running against other Ethereum clients Immutability
like go-ethereum. Truffle will re-deploy all of Security
our migrations at the beginning of every test Consensus Mechanism
file to ensure that we have a fresh set of
4.1 Consensus Mechanism
contracts to test against. Both Ganache and
Truffle Develop are significantly faster than Blockchain network rely on consensus
other clients when running automated tests. algorithms to validate transactions and ensure
Moreover, they contain special features which data integrity.
Truffle takes advantage of to speed up test Most Common:
runtime by almost 90.
Proof of Work (PoW) : Requires
miners to solve complex mathematical
3.2.2 Creating Workspace
problems, which ensures security but
consumes significant computational
As mentioned above, the Quickstart
power.
workspace resets the Block Chain on every
restart. Perhaps we found ourselves
prototyping in the Quickstart workspace to try
out a couple of things, but then we want to
save the Block Chain as a new workspace for
14
Figure 4.1: BITCOIN
KEY USES :
Immutable Records : Certificate
stored on a blockchain are immutable ,
meaning that cannot be altered or
tampered with once recorded.
Verification: All transactions and
changes made to the certificates can be
transactions.
tracked and audited. This allows
employers and institutions to verify the
Figure 4.1 : ETHEREUM
authenticity of certificates easily.
No Central Authority: Blockchain
Delegated Proof of Stake (DPoS) :
operates on a decentralized network.
Similar to PoS but allows token
This reduces the reliance on a central
holders to vote on a small group of
authority, minimizing the risk of fraud
validators to secure the network on
or errors.
their behalf .
15
Cost-Effectiveness: By automating
verification processes and eliminating
the need for intermediaries, Security: Blockchain uses hashing
16
agreement directly written into code.
They are stored and executed on
blockchain networks, enabling
automatic, transparent, and secure
transactions without intermediaries.
Smart contracts are a cornerstone of
blockchain technology, particularly in
platforms like Ethereum.
Cryptocurrency is a type of digital or
virtual currency that uses
Supply Chain :
cryptographic techniques for security
and operates on decentralized
networks, typically blockchain
technology. Unlike traditional
currencies issued by governments (like
USD or INR), cryptocurrencies are
generally decentralized, meaning they
Supply chain management (SCM)
are not controlled by any central
refers to the process of managing the
authority.
flow of goods, information, and
finances as they move from suppliers
Smart Contract :
to manufacturers, wholesalers,
retailers, and finally, consumers. A
well-optimized supply chain ensures
efficiency, cost-effectiveness, and
timely delivery of products or services.
Real Estate :
17
Real estate in blockchain technology is
transforming the industry by
introducing transparency, efficiency,
and security in transactions.
Healthcare :
Chapter 6
Disadvantages
Scalability: It cannot be scaled due to
the fixed size of the block for storing
information.
Ensures the secure and efficient Regulatory Issues: To add next block
18
applications is banned like bitcoin due world has found applications of blockchain
to some environmental issues. technology in several industries, where the
trust without the involvement of a centralized
Storage: It stores all nodes of network authority is desired. So welcome to the world
creates an issue with storage and of Blockchain. Blockchain technology is only
increasing transactions will requires going to grow in the fields of business,
more storage. finance, law, medicine, and real estate.
Whether you're an experienced Blockchain
developer, or you're aspiring to break into this
exciting industry, enrolling in our Blockchain
Certification Training program will help
individuals with all levels of experience to
19
[3] M. Nofer, P. Gomber, O. Hinz, and D.
Schiereck, "Blockchain," Business
Information Systems Engineering, vol. 59, pp.
183-187, Jun 2017.
20