0% found this document useful (0 votes)
6 views46 pages

Understanding Bitcoin: A Comprehensive Guide

Bitcoin (BTC) is a decentralized cryptocurrency introduced in 2009 by an anonymous entity known as Satoshi Nakamoto, designed for peer-to-peer transactions without third-party involvement. It operates on a blockchain, secured by a proof-of-work consensus mechanism, and has inspired numerous other cryptocurrencies. Bitcoin can be mined using specialized hardware or purchased on exchanges, with its value fluctuating significantly over time.

Uploaded by

vidyasri021
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 (0 votes)
6 views46 pages

Understanding Bitcoin: A Comprehensive Guide

Bitcoin (BTC) is a decentralized cryptocurrency introduced in 2009 by an anonymous entity known as Satoshi Nakamoto, designed for peer-to-peer transactions without third-party involvement. It operates on a blockchain, secured by a proof-of-work consensus mechanism, and has inspired numerous other cryptocurrencies. Bitcoin can be mined using specialized hardware or purchased on exchanges, with its value fluctuating significantly over time.

Uploaded by

vidyasri021
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

UNIT-5

Bitcoin

Bitcoin (BTC) is a cryptocurrency, a virtual currency designed to act as money


and a form of payment outside the control of any one person, group, or entity,
thus removing the need for third-party involvement in financial transactions. It
is rewarded to blockchain miners for the work done to verify transactions and
can be purchased on several exchanges.

Bitcoin was introduced to the public in 2009 by an anonymous developer or


group of developers using the name Satoshi Nakamoto.1

It has since become the most well-known cryptocurrency in the world. Its
popularity has inspired the development of many other cryptocurrencies. These
competitors either attempt to replace it as a payment system or are used as
utility or security tokens in other blockchains and emerging financial
technologies..

 Launched in 2009, Bitcoin is the world's largest cryptocurrency by


market capitalization.
 Unlike fiat currency, Bitcoin is created, distributed, traded, and stored
using a decentralized ledger system known as a blockchain.
 Bitcoin and its ledger are secured by proof-of-work (PoW) consensus,
which is also the "mining" process that introduces new bitcoins into the
system.
 Bitcoin can be purchased via various cryptocurrency exchanges.
 Bitcoin's history as a store of value has been turbulent; it has gone
through several boom and bust cycles over its relatively short lifespan.
 As the first decentralized virtual currency to meet widespread popularity
and success, Bitcoin has inspired a host of other cryptocurrencies in its
wake.
 In August 2008, the domain name [Link] was registered. Today, at
least, this domain is WhoisGuard Protected, meaning the identity of the
person who registered it is not public information.2
 In October 2008, a person or group using the false name Satoshi
Nakamoto announced the Cryptography Mailing List at [Link]:
"I've been working on a new electronic cash system that's fully peer-to-
peer, with no trusted third party." This now-famous white paper
published on [Link], entitled "Bitcoin: A Peer-to-Peer Electronic
Cash System," would become the Magna Carta for how Bitcoin operates
today.3
 On Jan. 3, 2009, the first Bitcoin block was mined—Block 0. This is also
known as the "genesis block" and contains the text: "The Times
03/Jan/2009 Chancellor on brink of second bailout for banks," perhaps
proof that the block was mined on or after that date, and maybe also as
relevant political commentary.4
 Bitcoin rewards are halved every 210,000 blocks. For example, the block
reward was 50 new bitcoins in 2009. On May 11, 2020, the third halving
occurred, bringing the reward for each block discovery down to 6.25
bitcoins.5
 One bitcoin is divisible to eight decimal places (100 millionths of one
bitcoin), and this smallest unit is referred to as a satoshi. If necessary,
and if the participating miners accept the change, Bitcoin could
eventually be made divisible to even more decimal places.
 Bitcoin, as a form of digital currency, isn't too complicated to
understand. For example, if you own a bitcoin, you can use your
cryptocurrency wallet to send smaller portions of that bitcoin as payment
for goods or services. However, it becomes very complex when you try
to understand how it works.
 .
 Bitcoin's Blockchain Technology
 Cryptocurrencies are part of a blockchain and the network required to
power it. A blockchain is a distributed ledger, a shared database that
stores data. Data within the blockchain is secured by encryption
methods.
 When a transaction takes place on the blockchain, information from the
previous block is copied to a new block with the new data, encrypted,
and the transaction is verified by validators—called miners—in the
network. When a transaction is verified, a new block is opened, and a
Bitcoin is created and given as a reward to the miner(s) who verified the
data within the block—they are then free to use it, hold it, or sell it.
 Bitcoin uses the SHA-256 hashing algorithm to encrypt the data stored in
the blocks on the blockchain. Simply put, transaction data stored in a
block is encrypted into a 256-bit hexadecimal number. That number
contains all of the transaction data and information linked to the blocks
before that block.
 Data linked between blocks is what led to the ledger being called a
blockchain.
 Transactions are placed into a queue to be validated by miners within the
network. Miners in the Bitcoin blockchain network all attempt to verify
the same transaction simultaneously. The mining software and hardware
work to solve the nonce, a four-byte number included in the block header
that miners are attempting to solve.
 The block header is hashed, or randomly regenerated by a miner
repeatedly until it meets a target number specified by the blockchain.
The block header is "solved," and a new block is created for more
transactions to be encrypted and verified.

How to Mine Bitcoin

A variety of hardware and software can be used to mine Bitcoin. When Bitcoin
was first released, it was possible to mine it competitively on a personal
computer; however, as it became more popular, more miners joined the
network, which lowered the chances of being the one to solve the hash. You
can still use your personal computer as a miner if it has newer hardware, but
the chances of solving a hash individually are minuscule.

This is because you're competing with a network of miners that generate


around 220 quintillion hashes (220 exa hashes) per second. Machines, called
Application Specific Integrated Circuits (ASICs), have been built specifically
for mining—can generate around 255 trillion hashes per second. In contrast, a
computer with the latest hardware hashes around 100 mega hashes per second
(100 million).67

To successfully become a Bitcoin miner, you have several options. You can use
your existing personal computer to use mining software compatible with
Bitcoin and join a mining pool. Mining pools are groups of miners that
combine their computational power to compete with the large ASIC mining
farms.

You increase your chances of being rewarded by joining a pool, but rewards
are significantly decreased because they are shared.
If you have the financial means, you could also purchase an ASIC miner. You
can generally find a new one for around $20,000, but used ones are also sold by
miners as they upgrade their systems. There are some significant costs such as
electricity and cooling to consider if you purchase one or more ASICs.

There are several mining programs to choose from and many pools you can
join. Two of the most well-known programs are CGMiner and BFGMiner.
When choosing a pool, it's important to make sure you find out how they pay
out rewards, what any fees might be, and read some mining pool reviews.

How Do You Buy Bitcoin?

If you don't want to mine bitcoin, it can be bought using a cryptocurrency


exchange. Most people will not be able to purchase an entire BTC because of
its price, but you can buy portions of BTC on these exchanges in fiat currency
like U.S. dollars. For example, you can buy bitcoin on Coinbase by creating an
account and funding it. You can fund your account using your bank account,
credit card, or debit card. The following video explains more about buying
bitcoin.

How Is Bitcoin Used?

Bitcoin was initially designed and released as a peer-to-peer payment method.


However, its use cases are growing due to its increasing value and competition
from other blockchains and cryptocurrencies

Bitcoin Consensus

Blockchain is a distributed decentralized network that provides immutability,


privacy, security, and transparency. There is no central authority present to
validate and verify the transactions, yet every transaction in the Blockchain is
considered to be completely secured and verified. This is possible only
because of the presence of the consensus protocol which is a core part of any
Blockchain network. A consensus algorithm is a procedure through which all
the peers of the Blockchain network reach a common agreement about the
present state of the distributed ledger. In this way, consensus algorithms
achieve reliability in the Blockchain network and establish trust between
unknown peers in a distributed computing environment. Essentially, the
consensus protocol makes sure that every new block that is added to the
Blockchain is the one and only version of the truth that is agreed upon by all
the nodes in the Blockchain. The Blockchain consensus protocol consists of
some specific objectives such as coming to an agreement, collaboration,
cooperation, equal rights to every node, and mandatory participation of each
node in the consensus process. Thus, a consensus algorithm aims at finding a
common agreement that is a win for the entire network. Now, we will discuss
various consensus algorithms and how they work.
1. Proof of Work (PoW): This consensus algorithm is used to select a miner
for the next block generation. Bitcoin uses this PoW consensus algorithm.
The central idea behind this algorithm is to solve a complex mathematical
puzzle and easily give out a solution. This mathematical puzzle requires a
lot of computational power and thus, the node who solves the puzzle as
soon as possible gets to mine the next block. For more details on PoW,
please read Proof of Work (PoW) Consensus
2. Practical Byzantine Fault Tolerance (PBFT): Please refer to the existing
article on practical Byzantine Fault Tolerance(pBFT).
3. Proof of Stake (PoS): This is the most common alternative to PoW.
Ethereum has shifted from PoW to PoS consensus. In this type of
consensus algorithm, instead of investing in expensive hardware to solve a
complex puzzle, validators invest in the coins of the system by locking up
some of their coins as stakes. After that, all the validators will start
validating the blocks. Validators will validate blocks by placing a bet on
them if they discover a block that they think can be added to the chain.
Based on the actual blocks added in the Blockchain, all the validators get a
reward proportionate to their bets, and their stake increase accordingly. In
the end, a validator is chosen to generate a new block based on its
economic stake in the network. Thus, PoS encourages validators through an
incentive mechanism to reach to an agreement.
4. Delegated Proof Of Stake (DPoS): This is another type of Proof of Stake
consensus algorithm. This type of consensus mechanism depends on the
basis of the delegation of votes. The users delegate their votes to other
users. Whichever user then mines the block will distribute the rewards to
the users who delegated to that particular vote. Refer to the
article Delegated Proof of Stake for more.
5. Proof of Burn (PoB): With PoB, instead of investing in expensive
hardware equipment, validators ‘burn’ coins by sending them to an address
from where they are irretrievable. By committing the coins to an
unreachable address, validators earn the privilege to mine on the system
based on a random selection process. Thus, burning coins here means that
validators have a long-term commitment in exchange for their short-term
loss. Depending on how the PoB is implemented, miners may burn the
native currency of the Blockchain application or the currency of an
alternative chain, such as bitcoin. The more coins they burn, the better their
chances of being selected to mine the next block. While PoB is an
interesting alternative to PoW, the protocol still wastes resources
needlessly. And it is also questioned that mining power simply goes to
those who are willing to burn more money.
6. Proof of Capacity: In the Proof of Capacity consensus, validators are
supposed to invest their hard drive space instead of investing in expensive
hardware or burning coins. The more hard drive space validators have, the
better their chances of getting selected for mining the next block and
earning the block reward.
7. Proof of Elapsed Time: PoET is one of the fairest consensus algorithms
which chooses the next block using fair means only. It is widely used in
permissioned Blockchain networks. In this algorithm, every validator on
the network gets a fair chance to create their own block. All the nodes do so
by waiting for a random amount of time, adding proof of their wait in the
block. The created blocks are broadcasted to the network for others’
consideration. The winner is the validator which has the least timer value in
the proof part. The block from the winning validator node gets appended to
the Blockchain. There are additional checks in the algorithm to stop nodes
from always winning the election, and stop nodes from generating the
lowest timer value.

Bitcoin Wallets
Bitcoin has gained widespread acceptance and continues to grow in popularity.
Unlike stocks at a stock brokerage, you can withdraw your cryptocurrencies
from a crypto exchange and store them in an outside wallet. The best Bitcoin
wallets make it easy (and maybe a little fun) to securely store and manage your
crypto portfolio.

If you’re looking to buy and store Bitcoin or other cryptocurrencies, you may
be on the hunt for the best Bitcoin wallet. We looked at a long list of Bitcoin
wallets focusing on cost, user experience, supported cryptocurrencies, and
other features. Keep reading for a look at some of the best available Bitcoin
wallets.

Best Bitcoin Wallets of 2023

 Best for Security: Trezor Model T


 Best for Integration: Ledger Nano X
 Best for Advanced Bitcoin Users: Electrum
 Best for Beginners: Exodus
 Best for Mobile Users: Mycelium

Bitcoin Blocks

What Is a Block (Blockchain Block)?

Blocks are data structures within the blockchain database, where transaction
data in a cryptocurrency blockchain are permanently recorded. A block records
some or all of the most recent transactions not yet validated by the network.
Once the data are validated, the block is closed. Then, a new block is created
for new transactions to be entered into and validated.

A block is thus a permanent store of records that, once written, cannot be


altered or removed.

KEY TAKEAWAYS

 A block is a place in a blockchain where information is stored and


encrypted.
 Blocks are identified by long numbers that include encrypted transaction
information from previous blocks and new transaction information.
 Blocks and the information within them must be verified by a network
before new blocks can be created.
 Blocks and blockchains are not used solely by cryptocurrencies. They
also have many other uses.

How a Block (Blockchain Block) Works

A blockchain network witnesses a great deal of transaction activity. When used


in cryptocurrency, maintaining a record of these transactions helps the system
track how much was or wasn't used and which parties were involved. The
transactions made during a given period are recorded into a file called a block,
which is the basis of the blockchain network.

A block stores information. There are many pieces of information included


within a block, but it doesn't occupy a large amount of storage space. Blocks
generally include these elements, but it might vary between different types:

 Magic number: A number containing specific values that identify that


block as part of a particular cryptocurrency's network.
 Blocksize: Sets the size limit on the block so that only a specific amount
of information can be written in it.
 Block header: Contains information about the block.
 Transaction counter: A number that represents how many transactions
are stored in the block.
 Transactions: A list of all of the transactions within a block.

The transaction element is the largest because it contains the most information.
It is followed in storage size by the block header, which includes these sub-
elements:

 Version: The cryptocurrency version being used.


 Previous block hash: Contains a hash (encrypted number) of the
previous block's header.
 Hash Merkle root: Hash of transactions in the Merkle tree of the current
block.
 Time: A timestamp to place the block in the blockchain.
 Bits: The difficulty rating of the target hash, signifying the difficulty in
solving the nonce.
 Nonce: The encrypted number that a miner must solve to verify the
block and close it.

One 32-bit number in the header is called a nonce—the mining program uses
random numbers to "guess" the nonce in the hash. When a nonce is verified,
the hash is solved when the nonce, or a number less than it, is guessed. Then,
the network closes that block, generates a new one with a header, and the
process repeats.

Different mechanisms are used to reach a consensus; the most popular for
cryptocurrency is proof-of-work (PoW), with proof-of-stake (PoS) becoming
more so because of the reduced energy consumption compared to PoW.

Mining's Relationship to Blocks

Mining is the term used for solving the number that is the nonce, the only
number that can be changed in a block header. It is also the process the
cryptocurrency's network uses if proof-of-work is used in the protocol.

Cryptocurrency mining is commonly thought to be a complex mathematical


problem; it is actually a random number generated through hashing. Hashing is
the process of encrypting information using the encryption method a
cryptocurrency uses. For example, Bitcoin uses SHA256 for its encryption
algorithm. For a miner to generate the "winning" number, the mining program
must use SHA 256 to hash random numbers and place them into the nonce to
see if it is a match.

Merkle Tree

Merkle tree also known as hash tree is a data structure used for data
verification and synchronization.
It is a tree data structure where each non-leaf node is a hash of it’s child nodes.
All the leaf nodes are at the same depth and are as far left as possible.
It maintains data integrity and uses hash functions for this purpose.
Hash Functions:
So before understanding how Merkle trees work, we need to understand how
hash functions work.
A hash function maps an input to a fixed output and this output is called
hash. The output is unique for every input and this enables fingerprinting of
data. So, huge amounts of data can be easily identified through their hash.
This is a binary merkel tree, the top hash is a hash of the entire tree.
 This structure of the tree allows efficient mapping of huge data and small
changes made to the data can be easily identified.
 If we want to know where data change has occurred then we can check if
data is consistent with root hash and we will not have to traverse the whole
structure but only a small part of the structure.
 The root hash is used as the fingerprint for the entire data.
For a Binary Merkel tree
Operation Complexity
Space O(n)
Searching O(logn)
Traversal O(n)
Insertion O(logn)
Deletion O(logn)
Synchronization O(logn)
Applications:
 Merkle trees are useful in distributed systems where same data should exist
in multiple places.
 Merkle trees can be used to check inconsistencies.
 Apache Cassandra uses Merkle trees to detect inconsistencies between
replicas of entire databases.
 It is used in bitcoin and blockchain.
Bitcoin Mining Difficulty

Before we even begin to understand what bitcoin mining difficulty means, we


need to know how mining works. We have covered this topic in detail before, so
we will just give you a little overview before getting into the different nuances
of difficulty. Following that, we will look at how mining difficulty is calculated
and how it changes to suit the network’s needs.
How does mining work? How long does it take to mine 1 Bitcoin?
Bitcoin’s network has several specialized nodes called “miners” who use
specialized equipment to solve cryptographically hard puzzles. If they are
successful, then they will get the opportunity to add blocks to the BTC
blockchain successfully. This is how it works:
 The miner picks up transactions waiting in the mempool and hashes them.

 They add a random hexadecimal value to the front of the hash and hashes the
entire value.
This hash needs to be less than a particular value, which is called “difficulty.”
What determines bitcoin mining difficulty? Why does BTC difficulty
increase?

#1 To maintain network integrity


The level of Bitcoin mining difficulty increases or decreases according to the
ease of mining within the protocol. Remember, Bitcoin needs to have a
consistent block time of 10 minutes. In other words, new BTC can be injected
into the circulating supply every 10 minutes. To make sure that this timing
doesn’t change the Bitcoin protocol:
 Increases network difficulty when it becomes easier for miners to mine.

 Decrease network difficulty when it becomes harder for miners to mine.


The Bitcoin network has a universal block difficulty. All valid blocks must have
a hash below the target. Mining pools also have a pool-specific share difficulty
setting a lower limit for shares.
#2 Relationship with hash rate
One of the critical metrics in judging the health of a proof-of-work network is
hash rate. Simply put, hashrate shows you how powerful the miners are within
the network. Higher the bitcoin network hashrate, higher it’s overall security
and speed. However, these networks need to keep their hashrate under control
for consistent block production. This is why, when hashrate becomes high, the
bitcoin difficulty eventually gets higher as well, making it tougher for miners to
mine easily within the network.
The inverse is also true.
If Bitcoin’s hashrate decreases, the network difficulty will reduce as well.
Hashrate may decrease because of the following reasons:
 Bitcoin currently has a high difficulty, which is why the miners are having a
tough time mining in the system.

 The price of BTC went down, which is why a lot of miners quit mining.
To understand the correlation between the two, let’s check out their graphs. Up
first, we have the hash rate.
After that, we have the bitcoin difficulty chart:
As you can see, there is a very close correlation between the two. Around
March 26, the network difficulty fell by 16% from 16.55 trillion to 13.9 trillion.
This was the largest crash in network difficulty since early 2013. To understand
why this happened this time around, look at how the hashrate dropped as well
just before the bitcoin difficulty drop. This dip occurred because of Bitcoin’s
price crash, which forced a lot of miners to quit operations.
How does Bitcoin calculate difficulty?
Bitcoin’s network difficulty changes every 2016 blocks. The formula used by
the network to calculate difficulty goes like this:
difficulty = difficulty_1_target / current_target
In the formula above:
 target is a 256-bit number. As per Bitcoin’s protocol, the targets are a custom
floating-point type with limited accuracy. Bitcoin clients approximate
difficulty based on this fact. This value is also known as bdiff.

 difficulty_1_target can be different depending on how you choose to measure


difficulty. Traditionally, it represents a hash where the leading 32 bits are
zero and the rest are one. In fact, this value is also known as pool difficulty or
pdiff.
Every single block stores a packed representation of bitcoin difficulty in their
blocks called “Bits.” This target usually appear as 0x1b0404cb (stored in little-
endian order: cb 04 04 1b).
A block calculates the target value via a predetermined formula. Eg. With the
packed target given above, i.e. 0x1b0404cb. The hexadecimal target is:
0x0404cb * 2**(8*(0x1b – 3)) =
0x00000000000404CB0000000000000000000000000000000000000000000000
00
Now let’s calculate bdiff and pdiff.
The highest possible target (difficulty_1_target) is defined as 0x1d00ffff or, in
hex form:
0x00ffff * 2**(8*(0x1d – 3)) =
0x00000000FFFF0000000000000000000000000000000000000000000000000
000
Now that we know this value, we can use this to calculate our bdiff using the
difficulty = difficulty_1_target / current_target formula
Now, as we have defined in the previous section, the current_target is
0x1b0404cb or
0x00000000000404CB000000000000000000000000000000000000000000000
000.
So, to calculate current difficulty:
0x00000000FFFF0000000000000000000000000000000000000000000000000
000 /
0x00000000000404CB0000000000000000000000000000000000000000000000
00
= 16307.420938523983
Hence, bdiff is 16307.420938523983.
Now, let’s calculate the pdiff. Mining pools tend to use non-truncated targets
which puts difficulty_1_target at
0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFF.
If that’s the case then for the same current_target, our pdiff will be:
0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF /
0x00000000000404CB0000000000000000000000000000000000000000000000
00
= 16307.669773817162
Transaction Verifiability

Before a transaction is added to the blockchain it must be


authenticated and authorised.

There are several key steps a transaction must go through before it is added to
the blockchain. Today, we’re going to focus on authentication using
cryptographic keys, authorisation via proof of work, the role of mining, and the
more recent adoption of proof of stake protocols in later blockchain networks.

Authentication

The original blockchain was designed to operate without a central authority (i.e.
with no bank or regulator controlling who transacts), but transactions still have
to be authenticated.

This is done using cryptographic keys, a string of data (like a password) that
identifies a user and gives access to their “account” or “wallet” of value on the
system.
Each user has their own private key and a public key that everyone can see.
Using them both creates a secure digital identity to authenticate the user via
digital signatures and to ‘unlock’ the transaction they want to perform.

Authorisation

Once the transaction is agreed between the users, it needs to be approved, or


authorised, before it is added to a block in the chain.

For a public blockchain, the decision to add a transaction to the chain is made
by consensus. This means that the majority of “nodes” (or computers in the
network) must agree that the transaction is valid. The people who own the
computers in the network are incentivised to verify transactions through
rewards. This process is known as ‘proof of work’.

Proof of Work

Proof of Work requires the people who own the computers in the network to
solve a complex mathematical problem to be able to add a block to the chain.
Solving the problem is known as mining, and ‘miners’ are usually rewarded for
their work in cryptocurrency.

But mining isn’t easy. The mathematical problem can only be solved by trial
and error and the odds of solving the problem are about 1 in 5.9 trillion. It
requires substantial computing power which uses considerable amounts of
energy. This means the rewards for undertaking the mining must outweigh the
cost of the computers and the electricity cost of running them, as one computer
alone would take years to find a solution to the mathematical problem.

The Power of Mining

The Cambridge Bitcoin Electricity Consumption Index estimates the bitcoin


mining network consumes almost 70 terawatt-hours (TWh) of electricity per
year, ranking it the 40th largest consumer of electricity by ‘country’. By way of
comparison, Ireland (ranked 68th) uses just over a third of Bitcoin’s
consumption, or 25 TWh, and Austria at number 42 consumes 64.6 TWh of
electricity per year, according to 2016 data compiled by the CIA.
The Problem with Proof of Work

To create economies of scale, miners often pool their resources together through
companies that aggregate a large group of miners. These miners then share the
rewards and fees offered by the blockchain network.

As a blockchain grows, more computers join to try and solve the problem, the
problem gets harder and the network gets larger, theoretically distributing the
chain further and making it ever more difficult to sabotage or hack. In practice
though, mining power has become concentrated in the hands of a few mining
pools. These large organisations have the vast computing and electrical power
now needed to maintain and grow a blockchain network based around Proof of
Work validation.

Proof of Stake

Later blockchain networks have adopted “Proof of Stake” validation consensus


protocols, where participants must have a stake in the blockchain - usually by
owning some of the cryptocurrency - to be in with a chance of selecting,
verifying & validating transactions. This saves substantial computing power
resources because no mining is required.

In addition, blockchain technologies have evolved to include “Smart Contracts”


which automatically execute transactions when certain conditions have been
met.

Forks

The decentralized nature of public blockchains (for example, Bitcoin and


Ethereum) means that participants on the network must be able to come to an
agreement as to the shared state of the blockchain(shared public ledger and
blocks and the blockchain protocol). Unanimous consensus amongst the
network nodes results in a single blockchain that contains verified
data(transactions) that the network asserts to be correct. However, many times,
the nodes in the network can’t come in a unanimous consensus regarding the
future state of the blockchain. This event leads to forks (like a tuning fork
used in experimental science), meaning that point in which the ideal ‘single’
chain of blocks is split into two or more chains which are all valid.
FORKS IN BLOCKCHAIN:
In simple terms, Forks in blockchain means copying the code and modifying it
to create a new software or product. In open-source projects Forks are very
common and used widely. So, cryptocurrencies like Ethereum and Bitcoin are
decentralized and open software so that anyone can contribute. As they are
open-sources they rely on their communities to make the software more secure
and reliable. Also open source with the help of fork can make user interface
more interactive and look good, helping in gaining more users worldwide. In
open source the code is visible to everyone, anyone can modify, edit, access
there is no copyright claims for such actions.
For example: Tor browser is an open source software, Linux one of the most
widely use Operating system is an open source system, in similar way Bitcoin
and Ethereum protocol are also open sourced.

An example GeeksforGeeks blockchain fork

Moving Ahead:

Lets us see the different types of FORKS one by one:


TYPES OF FORKS

Basically forks are divided into two categories i.e. Codebase Fork and Live
Blockchain Fork. And then Live Blockchain Fork is divided into further two
parts i.e. Intentional Fork and Accidental Fork, as you can see in the above
mentioned figure the Intentional fork is then further divided into two parts
i.e. Soft Fork and Hard Fork.

TYPES OF FORKS:

CODEBASE FORK: In codebase blockchain fork you can copy the entire
code of a particular software. Let us take BITCOIN as an example, so suppose
you copied the whole blockchain code and modified it according to your need,
say that you decreased the block creation time, made some crucial changes and
created a faster software than BITCOIN and publish / launch it has a new
whole software named against you, by completing the whole white paper work
process. So in these way a new BLOCKCHAIN will be created from an empty
blank ledger. It’s a fact that many of these ALT COINS which are now
running on the blockchain are been made in these way only by using the
codebase fork i.e. they have made little up and down changes in the code of
BITCOIN and created their whole new ALT COIN.
LIVE BLOCKCHAIN FORK: Live Blockchain fork means a running
blockchain is been divided further into two parts or two ways. So in live
blockchain at a specific page the software is same and from that specific point
the chain is divided into two parts. So in context to this fork the Live
Blockchain Fork can occur because of two reasons :
 ACCIDENTAL FORK / TEMPORARY FORK: When multiple miners
mine a new block at nearly the same time, the entire network may not agree
on the choice of the new block. Some can accept the block mined by one
party, leading to a different chain of blocks from that point onward while
others can agree on the other alternatives (of blocks) available. Such a
situation arises because it takes some finite time for the information to
propagate in the entire blockchain network and hence conflicted opinions
can exist regarding the chronological order of events. In this fork, two or
more blocks have the same block height. Temporary forks resolve
themselves eventually when one of the chain dies out (gets orphaned)
because majority of the full nodes choose the other chain to add new blocks
to and sync with. Example (TEMPORARY FORK / ACCIDENTAL
FORK): Temporary forks happen more often than not and a usual event
that triggers this fork is mining of a block by more than one party at nearly
the same time.
 INTENTIONAL FORK: In intentional fork the rules of the blockchain are
been changed, knowing the code of the software and by modifying it
intentionally. This gives rise to two types of forks which can occur based
on the backwards-compatibility of the blockchain protocol and the time
instant at which a new block is mined. So Intentional fork can be of two
types:
1. SOFT FORK: When the blockchain protocol is altered in a backwards-
compatible way. In soft fork you tend to add new rules such that they do
not clash with the old rules. That means there is no connection between the
old rules and new rules. Rules in soft fork are tightened. When there is a
change in the software that runs on the nodes (better called as ‘full nodes’)
to function as a network participant, the change is such that the new blocks
mined on the basis of new rules (in the Blockchain protocol) are also
considered valid by the old version of the software. This feature is also
called as backwards-compatibility. Example (SOFT FORK): The Bitcoin
network’s SegWit update added a new class of addresses (Bech32).
However, this didn’t invalidate the existing P2SH addresses. A full node
with a P2SH type address could do a valid transaction with a node of
Bech32 type address.

2. HARD FORK: When the blockchain protocol is altered in a non


backwards-compatible way. Hard fork is opposite of Soft fork, here the
rules are loosened. When there is a change in the software that runs on the
full nodes to function as a network participant, the change is such that the
new blocks mined on the basis of new rules (in the Blockchain protocol)
are not considered valid by the old version of the software. When hard
forks occur, new currency come into existence (with valid original
currency) like in the case of Ethereum (original : Ethereum, new :
Ethereum Classic) and Bitcoin (original : Bitcoin, new : Bitcoin cash).
Equivalent quantity of currency is distributed to the full nodes who choose
to upgrade their software so that no material loss occurs. Such hard forks
are often contentious (generating conflicts in the community). The final
decision to join a particular chain rests with the full node. If chosen to join
the new chain, the software has to be upgraded to make newer transactions
valid while the nodes who do not choose to upgrade their software continue
working the same. Example (HARD FORK): The new Casper update in
the Ethereum Blockchain in which the consensus protocol will change from
a type of Proof of Work (PoS) to a type of Proof of Stake (PoS). The nodes
which install the Casper update will use the new consensus protocol. Full
nodes that do not choose to install the Casper update will become
incompatible with the full nodes that do.
Reasons for the occurrence of a blockchain fork:
 Add new functionality: The Blockchain code is upgraded regularly. Since
most public blockchains are open source, it is developed by people from
around the world. The improvements, issues are created, resolved and new
versions are released when the time is suitable.
 Fix security issues: Blockchain (and cryptocurrency on top of it) is a
relatively new technology as compared to the traditional currency (notes,
coins, cheque), research is still underway to fully understand it. So,
versions are bumped and updates are released to fix the security issues that
arise in the way.
 Reverse transactions: The community can actually void all the transaction
of a specific period if they are found to be breached and malicious.

Future of the Blockchain Fork:

The future of blockchain forks is an area of great interest to many blockchain


enthusiasts and experts. While it is difficult to predict with certainty what will
happen in the future, there are some trends and developments that may give us
an idea of what to expect.
 One possibility is that we may see more soft forks in the future, as they are
generally less disruptive to the network and require less consensus to
implement. Soft forks can be used to add new features to the blockchain or
to improve its efficiency, without creating a new cryptocurrency.
 Another possibility is that we may see more contentious hard forks in the
future, as different groups within the community have different opinions on
the direction of the blockchain. This could lead to more splits in the
community, as some users choose to continue using the old version of the
blockchain while others switch to the new version.
 In recent years, there has also been a trend towards the development of
interoperability protocols and multi-chain architectures, which may reduce
the need for forks. These solutions aim to make it easier for different
blockchain networks to communicate with each other and share data,
without the need for a hard fork.
 It is also worth noting that as the blockchain ecosystem continues to
mature, there may be less need for major updates or changes that require a
fork. Instead, the focus may shift towards incremental improvements and
optimizations that can be implemented through soft forks or other means.
 Overall, the future of blockchain forks is likely to be shaped by a
combination of technical developments, community dynamics, and market
forces. As blockchain technology continues to evolve, it will be interesting
to see how the role of forks evolves along with it.

Double Spending

Blockchain is a list of blocks. Each block comprises some information


associated with some hash. Blockchain is used nowadays widely for
transactions. It is an immutable, distributed, and decentralized ledger. The
working of Blockchain is as follows. Suppose a user wants to make a
transaction. A block is created and sent to other users. Users validate the block
and the transaction gets executed. The block is added and the users get
incentives.

Understanding Double Spending

Although Blockchain is secured, still it has some loopholes. Hackers or


malicious users take advantage of these loopholes to perform their activities.
 Double spending means the expenditure of the same digital currency twice
or more to avail the multiple services. It is a technical flaw that allows
users to duplicate money.
 Since digital currencies are nothing but files, a malicious user can create
multiple copies of the same currency file and can use it in multiple places.
 This issue can also occur if there is an alteration in the network or copies of
the currency are only used and not the original one.
 There are also double spends that allow hackers to reverse transactions so
that transaction happens two times.
 By doing this, the user loses money two times one for the fake block
created by the hacker and for the original block as well.
 The hacker gets incentives as well for the fake blocks that have been mined
and confirmed.

How Does Double Spending Happen?

Double spending can never arise physically. It can happen in online


transactions. This mostly occurs when there is no authority to verify the
transaction. It can also happen if the user’s wallet is not secured. Suppose a
user wants to avail of services from Merchant ‘A’ and Merchant ‘B’.
 The user first made a digital transaction with Merchant ‘A’.
 The copy of the cryptocurrency is stored on the user’s computer.
 So the user uses the same cryptocurrency to pay Merchant ‘B’
 Now both the merchants have the illusion that the money has been credited
since the transactions were not confirmed by the miners.
This is the case of double spending.

Example: Suppose a user has 1 BTC. He/She wants to avail of services from
merchant A and merchant B. The user creates multiple copies of the same
BTC and stores it. The user first sends the original BTC to Merchant A and
gets the service. Simultaneously, the user sends the copied version of 1 BTC to
Merchant B. Since the second transaction was not confirmed by other miners,
the merchant accepts the bitcoin and sends the service. But the cryptocurrency
that was sent is invalid. This is the case of Double Spending.

Types Of Double Spending Attacks

There are different types of Double Spending attacks:


 Finney Attack: Finney Attack is a type of Double spending Attack. In this,
a merchant accepts an unauthorized transaction. The original block is
eclipsed by the hacker using an eclipse attack. The transaction is performed
on an unauthorized one. After that, the real block shows up and again the
transaction is done automatically for the real block. Thus the merchant
loses money two times.
 Race attack: is an attack in which there is a ‘race’ between two
transactions. The attacker sends the same money using different machines
to two different merchants. The merchants send their goods but transactions
get invalid.
 51% Attack: This type of attack is prevalent in small blockchains. Hackers
usually take over 51% of the mining power of blockchain and therefore can
do anything of their own will.
How Bitcoin Handles Double Spending?

Bitcoin is one of the most popular blockchains. To combat Double spending it


uses some security measures. There are two types of examples of double
spending in BTC.
1. The first case is making duplicates of the same bitcoin and sending it to
multiple users.
2. The second case is performing the transaction and reversing the already
sent transaction after getting the service.
To tackle these double-spending issues, some security measures are taken.
They are:
 Validation: Validation of transactions by a maximum number of nodes in
the network. Once a block is created, it is added to a list of pending
transactions. Users send validation for the block. If the verifications are
done then only the block is added to the blockchain.
 Timestamp: The confirmed transactions are timestamped, therefore they
are irreversible. If a transaction is involved with a bitcoin it is verified and
done. But in the future, if other transactions are made with the same
bitcoin, the transactions will be canceled.
 Block Confirmations: Merchants get block confirmations so that they are
assured that there was no case of double spending. In bitcoin, a minimum
of 6 confirmations are done.
 Saving copies: A copy of each transaction is kept at each node so in case
of network failure the whole network does not go down.
These security features have reduced double spending to a large extent. Let us
discuss a detailed example of how bitcoin handles double-spending.
 A user wants to spend 2 BTC. He/She can create multiple copies of the
same cryptocurrency.
 The user can send the same cryptocurrency to two different addresses say
‘Bob’ and ‘Alice’.
 Both of these transactions are sent to the pool of unconfirmed transactions.
 The first transaction T1 would be approved via the confirmation
mechanism.
 The confirmation mechanism states that a minimum of six confirmations by
miners should be done for block validation. The block is added to the
network.
 However, the second transaction T2 didn’t get sufficient confirmation so it
would be recognized as invalid by the confirmation process. The block with
the highest number of confirmations is accepted and the other one is
rejected. So transaction T1 is valid, and Alice received the bitcoin.
Solutions To Prevent Double Spending

Double Spending can be prevented using two approaches: Centralized and


Decentralized
 Centralized Approach: In this case, a secured third party is employed to
verify the transactions. The third-party can track each of the user’s
balances. Suppose a user makes a transaction. The third-party identifies the
transaction with a unique identity. Then it verifies the transaction and
allows the transaction. The problem is that suppose we want to make
transactions with other countries where a third party is not required. So in
such cases, decentralized systems come into play. another drawback is if
the whole system fails, the users cannot have access.
 Decentralized Approach: This approach is used by Bitcoin. In this, there
is no involvement of central authority. Each transaction is verified using
powerful algorithms. The decentralized approach proved to be more secure
than the centralized approach. Protocols are established and each protocol
does its job at each step. Therefore this also promotes transparency.
Altcoin

Altcoins are generally defined as all cryptocurrencies other than Bitcoin (BTC).
However, some people consider altcoins to be all crytocurrencies other than
Bitcoin and Ethereum (ETH) because most cryptocurrencies are forked from
one of the two. Some altcoins use different consensus mechanisms to validate
transactions and open new blocks, or attempt to distinguish themselves from
Bitcoin and Ethereum by providing new or additional capabilities or purposes.

Most altcoins are designed and released by developers who have a different
vision or use for their tokens or cryptocurrency. Learn more about altcoins and
what makes them different from Bitcoin.

 The term altcoin refers to all cryptocurrencies other than Bitcoin (and for
some people, Ethereum).
 There are tens of thousands of altcoins on the market.
 Altcoins come in several types based on what they were designed for.
 The future value of altcoins is impossible to predict, but if the blockchain
they were designed for continues to be used and developed, the altcoins
will continue to exist.

Understanding Altcoins

"Altcoin" is a combination of the two words "alternative" and "coin." It is


generally used to include all cryptocurrencies and tokens that are not Bitcoin.
Altcoins belong to the blockchains they were explicitly designed for. Many are
forks—a splitting of a blockchain that is not compatible with the original
chain—from Bitcoin and Ethereum. These forks generally have more than one
reason for occurring. Most of the time, a group of developers disagree with
others and leave to make their own coin.

Many altcoins are used within their respective blockchains to accomplish


something, such as ether, which is used in Ethereum to pay transaction fees.
Some developers have created forks of Bitcoin and re-emerged as an attempt to
compete with Bitcoin as a payment method, such as Bitcoin Cash.

Others fork and advertise themselves as a way to raise funds for specific
projects. For example, the token Bananacoin forked from Ethereum and
emerged in 2017 as a way to raise funds for a banana plantation in Laos that
claimed to grow organic bananas.1
Types of Altcoins

Altcoins come in various flavors and categories. Here’s a brief summary of


some of the types of altcoins and what they are intended to be used for.

Payment Token
As the name implies, payment tokens are designed to be used as currency—to
exchange value between parties. Bitcoin is the prime example of a payment
token.

Stablecoins
Cryptocurrency trading and use have been marked by volatility since launch.
Stablecoins aim to reduce this overall volatility by pegging their value to a
basket of goods, such as fiat currencies, precious metals, or other
cryptocurrencies. The basket is meant to act as a reserve to redeem holders if
the cryptocurrency fails or faces problems. Price fluctuations for stablecoins
are not meant to exceed a narrow range.

Notable stablecoins include Tether's USDT, MakerDAO's DAI, and the USD
Coin (USDC). In March 2021, payment processing giant Visa Inc. (V)
announced that it would begin settling some transactions on its network in
USDC over the Ethereum blockchain, with plans to roll out further stablecoin
settlement capacity later in 2021.2

Security Tokens
Security tokens are tokenized assets offered on stock markets. Tokenization is
the transfer of value from an asset to a token, which is then made available to
investors. Any asset can be tokenized, such as real estate or stocks. For this to
work, the asset must be secured and held. Otherwise, the tokens are worthless
because they wouldn't represent anything. Security tokens are regulated by the
Securities and Exchange Commission because they are designed to act as
securities.

In 2021, the Bitcoin wallet firm Exodus successfully completed a Securities


and Exchange Commission-qualified Reg A+ token offering, allowing for $75
million shares of common stock to be converted to tokens on the Algorand
blockchain.3 This was a historic event because it was the first digital asset
security to offer equity in a United States-based issuer.

Utility Tokens
Utility tokens are used to provide services within a network. For example, they
might be used to purchase services, pay network fees, or redeem rewards.
Filecoin, which is used to buy storage space on a network and secure the
information, is an example of a utility token.4

Ether (ETH) is also a utility token. It is designed to be used in the Ethereum


blockchain and virtual machine to pay for transactions. The stable coin
USTerra uses utility tokens to attempt to maintain its peg to the dollar—which
it lost on May 11, 2022—by minting and burning two utility tokens to create
downward or upward pressure on its price.5

Utility tokens can be purchased on exchanges and held, but they are meant to
be used in the blockchain network to keep it functioning.

Meme Coins
As their name suggests, meme coins are inspired by a joke or a silly take on
other well-known cryptocurrencies. They typically gain popularity in a short
period of time, often hyped online by prominent influencers or investors
attempting to exploit short-term gains.

Many refer to the sharp run-up in this type of altcoins during April and May
2021 as "meme coin season," with hundreds of these cryptocurrencies posting
enormous percentage gains based on pure speculation.6

An initial coin offering (ICO) is the cryptocurrency industry’s equivalent of


an initial public offering (IPO). A company looking to raise money to create a
new coin, app, or service launches an ICO to raise funds.
Governance Tokens
Governance tokens allow holders certain rights within a blockchain, such as
voting for changes to protocols or having a say in decisions of a decentralized
autonomous organization (DAO). Because they are generally native to a private
blockchain and used for blockchain purposes, they are utility tokens but have
come to be accepted as a separate type because of their purpose.7

Pros and Cons of Altcoins

Pros

 Improve upon another cryptocurrency's weaknesses


 Higher survivability
 Thousands to choose from

Cons

 Lower popularity and smaller market cap


 Less liquid than Bitcoin
 Difficult to determine use cases
 Many altcoins are scams or lost developer and community interest

Pros of Altcoins Explained

 Altcoins are "improved versions" of the cryptocurrency they derived


from because they aim to plug perceived shortcomings.
 Altcoins with more utility have a better chance of surviving because they
have uses, such as Ethereum’s ether.
 Investors can choose from a wide variety of altcoins that perform
different functions in the crypto economy.

Cons of Altcoin Explained

 Altcoins have a smaller investment market compared to Bitcoin. Bitcoin


has generally hovered around 40% of the global cryptocurrency market
since May of 2021.8
 The altcoin market is characterized by fewer investors and less activity,
resulting in thin liquidity.
 It is not always easy to distinguish between different altcoins and their
respective use cases, making investment decisions even more
complicated and confusing.
 There are several "dead" altcoins that ended up sinking investor dollars.
Medical Record Management

Instead of using the traditional centralized databases, the Ethereum-based


blockchain is applied to our designed system framework of medical record
management to ensure the security of data. The medical records are stored
within individual nodes in the blockchain networks by utilizing the smart
contracts. The automatic smart contracts for the administration procedure are
also designed with an aim to reducing the waste of human resource and
speeding up the medical process.

The presented medical record management system is essentially rooted in the


Ethereum-based blockchain architecture. The management framework is
developed and established based on the relationship among the smart contracts.
The proposed architecture is modified from the framework in [2]. The whole
system is viewed as a private blockchain network, where all medical records are
stored to guarantee data security, privacy and integrity. Innovatively combined
with the data exchange mechanism in [13], the user identity is directly
recognized by the system and the corresponding privilege is authorized to
ensure data integrity in the blockchain networks.

Blockchain-based medical record management system

Figure 1 illustrates the proposed medical record management system with smart
contracts. There are three types of smart contracts, including registrar contract,
patient-provider relationship contract and summary contract.

Figure 1.

Proposed smart contract-based medical management system.


Registrar contract (RC)

Similar to [2], this contract maps member identification strings to the Ethereum
address identity. All the registered members are divided into two groups,
patients and medical personnel. Each identity has different access rights for the
proposed system.

Authorized privilege of patients:

1. Review their own medical records. b) Authorize their own medical records.

Authorized privilege of the medical personnel:

1. Create/modify the authorized medical records. b) Review the authorized


medical records. Notice that different kinds of the medical personnel has
different authorized or restricted rights.

Patient-provider relationship contract (PPR)

Each PPR smart contract is a medical certificate. The PPR smart contract is
utilized to record the current situation of medical records, details of diagnosis
and the access permission of different summary contracts. Sometimes other
relevant PPR diagnostic address information will also be included. All summary
smart contracts must be licensed by the owner of the PPR contract to access the
PPR smart contract.

As shown in Figure 2, the medical personnel will be allowed to modify or read


only based on the access right in the summary contracts after getting the
permits. Moreover, the administration system can track the current diagnosis by
the assistance of the PPR contract.
Figure 2.

Authorization procedure of getting medical record permission.

3.1.3 Summary contract (SC)

This contract holds a list of references to PPRs, locating patients’ medical


record history. The patient-oriented medical record classification structure in the
proposed system is designed. Each record is viewed as an PPR smart contract.
The proposed medical record structure is shown in fig.
Figure 3.

Proposed personal medical record.

3.2 Private blockchain network

The deployment of the private blockchain network is illustrated in Figure 4,


which is applied for the level of care. The main private blockchain network is
plotted by the solid lines. The critical network devices are maintained by the
medical centers or hospitals, and the distributed databases among them must be
synchronized. The clinics only need to synchronize with the nearby blockchain
network nodes to ensure their database stay latest and correct.
Figure 4.

Deployment of private blockchain.

Dotted lines stand for the data requests to the blockchain network from patients
whom made inquiry for medical record. In this case, the main blockchain
network nodes (e.g. the medical center or hospital) are responsible to deal with
the requests since their network equipments are capable of handling the heavy
network traffic due to plenty of requests. As a primary node in blockchain
network, the synchronization speed and correctness should be guaranteed.

3.3 System workflow

How the proposed management system works is presented in Figure 5.


Figure 5.

System workflow.

3.3.1 New entry

The medical personnel uploads the diagnosis to provider B Node.

3.3.2 External process and outside process

The external management system detects the updates from the blockchain
databases, automatically validates the latest data and notifies the patients of the
new updates.

3.3.3 Update nodes

The blockchain network automatically synchronizes all nodes and offers the
latest information to the patient node.
3.3.4 Notification from provider B

The patient will be notified by the information about who updated the medical
record and then checks these updates.

3.4 Limitations

With the blockchain-based technique for distributed databases, the additional


network facilities and storage devices for network nodes are required to
stabilize the whole system. However, it helps save human resource, reduce
human errors and accelerate administration process.
Miscellaneous

1— What is a cryptocurrency?

Cryptocurrencies are digital-based currencies that use cryptographic techniques


to regulate the generation of currency and verify the transfer of funds; without
the need for a trusted third party. The currencies are based on blockchain
technology; a secure public ledger that can be programmed to record digital
information. The first and most well-known cryptocurrency, known
as Bitcoin was proposed in 2008 by an anonymous developer(s) Satoshi
Nakamoto in the whitepaper ‘Bitcoin: A Peer-to-peer Electronic Cash System’.

2 — The Blockchain

Bitcoin consists of a network of computers connected through the internet


called nodes. Anyone with a computer and internet connection can join the
network by running a Bitcoin software. Every node on the network contains
an identical copy of a distributed ledger; a database containing all previous
transaction history on the network. This is also known as the blockchain. As
anyone can join the network, nodes are unable to fully trust each other and to
combat this, all transaction history is made public, relying on all nodes to
agree on one single truth. This, however, does not compromise the user’s
anonymity as the database does not contain any personal information, only the
user’s public Bitcoin address and transaction history. Users can also create
multiple Bitcoin addresses from a single set of public/private keys, further
increasing secrecy.
We describe the network as being decentralized as there is no third party
determining the validity of transactions, this is instead done by proof-of-work.
This increases security since unlike third parties (e.g. banks) if there is an
attempted attack on the network only one node is affected rather than the whole
system.

2.1 — Transactions

Before we can make a transaction, we must first generate our public


key, private key, and public address. This process will be demonstrated in part
3. These allow us to receive, send and validate Bitcoin transactions using
cryptographic hash functions and the ECDSA (Elliptical Curve Digital
Signature Algorithm).

Bitcoin Transactions — Bitcoin Whitepaper 2008

A transaction consists of the transfer of Bitcoin from one or more inputs to one
or more outputs. The image above shows us the process of a transaction, each
larger box representing a separate transaction. To create a new transaction, we
use the payee’s public key (Owner 2) and the previous transaction
inputs (transactions in which the user received their Bitcoin) to create a hash. To
verify this transaction came from them, the sender (Owner 1) uses their private
key to sign; approving the transaction. The payee can also verify that the sender
is entitled to spend the value of the transaction by using the senders public key
to validate the signature (highlighted in green).

As all transactions are made public, we can find transaction details publicly
online as shown below. As we can see at the top, transactions are given a unique
transaction value as a 256-bit hash which is used to uniquely identify and
validate the transaction. This hash is calculated by running the transaction code
through the SHA-256 algorithm (part 4).

The transaction contains the following data:

 Size: The size of the transaction in bytes

 Fee Rate: The amount charged for the transaction per kB (Paid to Miner)

 Received Time/Mined Time: Time the transaction was confirmed

 Included in Block: The hash of the block the transaction is included in

In the ‘Details’ section, we can see the Inputs and outputs of the transaction. On
the left, the inputs show the transactions sent to the sender’s address that they
have the rights to spend. The right-hand side shows the address the sender has
sent funds to. In this case, the sender has sent 2.484822 BTC to a single
address (S = spent). The whole input is sent, and the remaining amount after
fees are deducted is refunded back to the sender, as shown from the 2nd output
of 4.835 BTC (U = unspent).
The transaction is then broadcasted to the network and added to a ‘pool’ of
transactions, ready to be added to a block. As this transaction has already been
added to a block, we can see ‘2 confirmations’ which is the number of nodes
that have confirmed the validity of the transactions block. This value is low as
this block is new and has not been received by many nodes yet.

2.2 — Blocks

Before transactions are added to the blockchain, they must first be placed into a
block. A block contains a group of transactions. We can also find block data
publicly online. Similar to the transaction data, the block has a unique 256-bit
hash value which is used to identify and validate the block. This value is
computed by applying the SHA-256 algorithm (part 4) to the raw code of the
transaction. Examples of a blocks raw data and processed data is shown below.

Raw Block Data from [Link]


The block also contains the following data:

 Number of transactions: How many transactions the block contains

 Height: The number of the block in the blockchain

 Block Reward: The amount rewarded to the miner for computing the block

 Timestamp: The time the block was added

 Mined by: Who mined the block (Can appear anonymous)

 Merkle Root: The combined hash of all the transactions in this block

 Previous Block: The previous block’s hash

 Difficulty: A value used to calculate how difficult the block is to solve (This
value is adjusted every 2016 blocks to aim for » 10 minutes computation
time)

 Bits: The difficulty (hexadecimal format)

 Size: The total size of the block (In this case 926450 bytes » 0.926 MB
which is close to the maximum capacity of 1MB)

 Version: Signals to the rest of the network about intentions to update

 Nonce: A value that is changed to find a solution for the block

2.2.1 — Miners

Miners are a specific type of node that specifically aim to solve a computational
problem that is required to add a block to the blockchain. If a miner
successfully computes this problem, and the block is used in the blockchain,
the miner is rewarded with newly distributed coins. This is called the block
reward. The block reward is sent in the form of a coinbase transaction; a
specific type of transaction added to the start of the block by the miner. As
they are newly distributed coins, there are no inputs and the outputs can be
chosen by the owner of the miner.

As there is a limited amount of Bitcoin (≈ 21 million), the Bitcoin reward


must decrease over time to prevent all Bitcoins from being distributed too soon.
The first block reward began at 50 BTC and this amount halves every 210,000
blocks. This is the only way new Bitcoins can be added to the network. The
equation below shows the formula for the total number of Bitcoins mined per
halving with 𝑖 = the reward era. Summing from the 0th period to the 32nd
period, we get our total number of Bitcoins » 21 million.

Bitcoin Supply Formula


Bitcoin halving chart showing the number of Bitcoins distributed and inflation
rate. The x-axis shows the block rewards (above x line) for each block period
(below x line) — [Link]

As blocks are solved in an average of 10 minutes, it is predicted that all Bitcoins


will have been mined by the year 2140 ([Link], n.d.). After all coins
have been mined, transaction fees will likely increase, becoming the new reward
for miners. The figure above shows that as the block rewards halve every 210
(thousand) blocks, the inflation rate decreases. This is determined by Bitcoin’s
code to make it impossible to mine more than 21 million Bitcoins. As the total
amount of Bitcoin tends towards its limit, the inflation rate tends towards 0 as
the currency gains more purchasing power over time.

2.3 — Timestamp Servers

A problem that arises with the current transaction process described is ‘double-
spending’. Double-spending is the process of spending the same money more
than once. With regular currency this is not a problem as either cash is handed
over to the payee or a third party (e.g. a bank) is able to regulate what money has
already been spent by the user. As Bitcoin transactions take time to process and
are not regulated, we must have a method to prevent someone using the same
coins to broadcast another transaction before the first transaction has been
processed. To combat this, we use timestamping.

Timestamping is a way of showing that blocks are in chronological order by


including the time the block was added and the timestamp of the previous
block in the blocks hash value. This proves that the data in the hash hasn’t been
changed after the hash was computed as this would produce a completely
different hash in the next block. Because each timestamp also includes the
timestamp from the previous block (see diagram below), this forms
an unchangeable record of the transaction order and is increasingly secured
after every new block. The only way an attacker would be able to change the
information of a block (allowing for double-spending) is if they had more than
half the total computing power of the entire Bitcoin network. Even with 51%, the
attacker would struggle to solve multiple blocks in order quicker than the
remaining 49%. This prevents double-spending as if a user were to make a
transaction using an input and whilst it is still being processed, use the same
input for another transaction:

 The first block is verified and added to the blockchain

 The next block contains data from the previous block including the first
transactions input

 The next block rejects the transaction as it knows the input has already been
used

Diagram showing how the previous hash is used in the computation of the
current block's hash — Bitcoin Whitepaper 2008

2.4 — Proof-of-Work

Before the block can be added to the blockchain, the mining node responsible for
creating the block must prove that it has solved a computationally difficult
problem. The miner does this by repeatedly alternating a nonce value that when
hashed by SHA-256 along with the Merkle root and previous blocks hash;
returns a hash that is less than a defined value determined by the current
difficulty (beginning with a certain number of zeros).

2.4.1 — Merkle Root

The Merkle root is the combination of all the transaction’s hashes in the
block. The diagram below shows how the Merkle root is calculated. In this
example, there are 4 transactions (Tx0 — Tx3) in the block. The first step is to
hash each transaction using SHA-256. We then pair the hashes in order of
arrival and perform a second hash on each pair. If there are an odd number of
hashes in a stage, the single hash is duplicated and hashed with itself. Once there
is only one hash left, we assign this the Merkle Root (Root Hash).

Transactions hashed in a Merkle tree — Bitcoin Whitepaper 2008


Once a miner has found a nonce value that when hashed with the Merkle root
and previous block hash; gives a valid solution, the block is broadcast by the
node across the Bitcoin network. The moment other nodes receive this
broadcast, they validate the block and its transactions and once authenticated,
they update their blockchain with the new block. The broadcast is
then relayed to other nodes. If the block is not valid, the node will not relay the
broadcast. Miners will now begin attempting to solve the next block using the
hash of the newly broadcasted block.

2.4.2 — Forks

Let’s say two or more separate nodes broadcast a block at the same time, which
will be accepted as the next in the blockchain? Nodes validate the first block
they receive and add this to their chain. The node may then receive another
block that stems from the same previous block. The blockchain defines the truth
as the longest chain. Once other blocks have been received and added to one
side of the fork, this fork is now longer meaning it is more likely to be the truth.
Once one side has significantly more blocks than the other, the shorter chain is
ignored, and the transactions (excluding the coinbase transaction which is made
null) are added back to the pool to be added to a new block. As it gets
increasingly more unlikely each fork’s new blocks are solved at the same time,
these tend to only last for less than a few blocks.
Bitcoin fork where the longest chain is the ‘truth’

Forks can also occur when a node suggests an update to the Bitcoin protocol.
This means that someone suggests an improvement to the network, broadcasting
their update to other nodes. If a node agrees on a new protocol it will begin to
use it. As some nodes may choose to decline the update, we are left with a fork
of updated nodes and original nodes. The fork with the majority of nodes is
accepted as the new Bitcoin core and if the other fork still decides they do not
want to implement the update, we are left with a ‘hard fork’. An example of this
is ‘Bitcoin Cash’ which was formed in 2017 and has an increased block size of
8MB. For someone holding an amount of the original currency, they also receive
the same amount of the new fork’s currency.

Bitcoin Hard Fork

You might also like