BCT Unit-2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

UNIT-2

2.1: Types of Blockchain


What are the types of Blockchain
There are 4 different types of Blockchain that are being used currently.
1. Public Blockchain
2. Private Blockchain
3. Consortium/ Federated Blockchain
4. Hybrid Blockchain
Blockchain based on working principle, can also be classified into two types
1. Permissionless Blockchain and
2. Permissioned Blockchain

1.Public Blockchain
Public Blockchain, as the name suggests, is public. A public blockchain is completely decentralized and does not have
a single entity that controls the network.
In this type of Blockchain, anyone with an internet connection can join the network and participate in reading, writing,
or auditing within the Blockchain. Hence anyone can review anything at a given point of time on a public blockchain
as long as they are connected to the network. Any node can also choose to leave the network and rejoin and still get
the chain of data, since the time they left.
Public blockchain can also be called Permissionless Blockchain because it allows any user to create a personal address
and join the blockchain network, i.e., become a ‘node’ of the network. Also, the public blockchains do not restrict the
rights of the nodes on the blockchain network.
Another critical point to remember is that these types of Blockchain are more transparent and secure than
permissioned blockchains because there are many nodes to validate transactions. Thus, it would be difficult for bad
actors to collude on the network. Also, it is not possible to modify or alter the data once it has been validated on the
Blockchain.
(i) To be part of a public blockchain, one needs to download the code without needing any permission from anyone
and start running a public node on their local device. Once this is done, he can then validate transactions in the
network, thus participating in the consensus process — the process for determining what blocks can be added to the
Blockchain.
(ii) Anyone in the world can send transactions through the network and can expect them to be included in the
Blockchain if they are valid.
(iii) In a public blockchain, anyone in the world can access and read Blockchain transactions using a block explorer,
which is a program or a website that allows a user to search and navigate the blocks of a Blockchain, their contents,
and relevant details.
(iv) Speed of transactions in the public blockchain is slower than in the case of private blockchain.
Examples: To date, public blockchains are primarily used for exchanging and mining cryptocurrency. A few examples
of cryptocurrency public blockchain platforms include Bitcoin, Ethereum, Litecoin, etc. Ethereum is actually the most
popular public blockchain at present.
Limitations:
One may face some challenges while using a public blockchain. For instance,
(i) Difficult Fraud Tracking: The transactions on the public blockchain can be done anonymously or pseudo
anonymously and are not tied directly to the real identity of the user. These transactions are linked to an account
address comprised solely of numbers and letters. With no real-world identity attached to this address, it is impossible
to track the transaction’s originator. It raises a very critical concern, what if activities like fraud, hacking, or money
laundering take place in this type of Blockchain. How will the guilty party or person be tracked and punished?
(ii) Lack of governance and regulations: The public blockchain being completely open and decentralized makes it
susceptible to a lack of proper regulation and governance by an authorized body. Thus, there is no safe upgrade path
for any protocols, and there is no one who can be held responsible for setting and maintaining the network standards.
It is definitely good to keep the development of Blockchain technology as decentralized as possible; however, we still
need some organization that can look after its features, upgrades, and code of conduct. For instance, if a developer
designs a new standard or protocol but gets busy and forgets to respond, then the progress on that protocol halts
regardless of how valuable that protocol is for everybody. You cannot hold anyone responsible for maintaining the
network standard, thus making the entire system dicey and skeptical. Therefore there is a need for leadership that
needs to look after all these aspects. Additionally, the public blockchains are not suitable for use in any internal system
and for projects that have strict criteria to follow.
(iii) Slow speed and massive consumption of energy: Another critical area of concern while using public blockchain
technology is its speed and the energy it consumes. Public blockchains are slow because it takes time for the network
to reach a consensus. For instance, public blockchains like bitcoin manage to process seven transactions per second
compared to Visa, which can do 1700 transactions per second. Also, public blockchains like Bitcoin rely on a
consensus mechanism- Proof of Work to validate transactions and add new blocks of transactions to the network. In
this process, a lot of energy gets consumed while solving complex mathematical problems to validate the transactions
and create a block. As per the studies published in June 2017, each bitcoin transaction consumes 80,000 times more
electricity than a Visa credit card transaction. But various other consensus mechanisms have been proposed, like Proof
of Stake, which uses far less electricity.

2.Private Blockchain
The second type of blockchain is Private Blockchain, where the network participants have control over who can join
the network and who can participate in the consensus process. This is in contrast to public blockchain which is open
for anyone to participate in the network.
In a private blockchain, access to the blockchain is limited to selected participants for example, those participants
within an organization. Access controls in the network will vary for every participant, and the Regulatory Authority or
central organization would decide on various activities inside the network starting from joining the network until
executing any of the functionalities in this closed network.
In this platform, the digital identities of the participants need to be managed and monitored by the Regulatory
Authority. Therefore, it is not necessarily decentralized even among its members but is a centralized system that uses
distributed ledger technology.
However, private blockchain offers several advantages over public blockchain:
(i) In the case of the public blockchain, the credentials of nodes are not known; therefore, nobody can decipher who
these validators are, which increases the risk of malicious activities. But in the case of a private blockchain, the
credentials of participating nodes are present on the blockchain; therefore, it is much easier to track where the fraud
happened.
(ii) Additionally, since private blockchains are generally smaller than public blockchains and have far fewer
participants, therefore it takes less time for the network to reach a consensus. As a result, more transactions can take
place. Private blockchains can process thousands of transactions per second. Also, they take up a lot less energy and
power to validate transactions. On the contrary public blockchain networks, which usually have thousands of
computers to verify transactions, consume tons of energy.
(iii) Private blockchain provides exciting opportunities for businesses to leverage trustless and transparent activities
for internal and business-to-business use cases. For instance, banks and financial institutions can use private
blockchain as they are regulated entities that cannot operate over open protocols or public blockchain without
performing due diligence of the parties involved in the transaction. Additionally, with the advent of smart contracts,
this technology could eventually replace many centralized businesses.
Limitations:
There are certain challenges associated with the private blockchain. For instance,
(i) Centralization of private blockchain is one of its biggest disadvantages. Blockchain was built to avoid
centralization, and private blockchain inherently becomes centralized due to its private network.
(ii) The second disadvantage of using private blockchain is trust. The credibility of a private blockchain network relies
on the credibility of the authorized nodes. They need to be trustworthy as they are verifying and validating
transactions.
(iii) Security is another concern while using a private blockchain. With fewer nodes, it is easier for malicious hackers
to gain control of the network. Thus, compared to the public blockchain, a private blockchain is far more at risk of
being hacked or having data manipulated.

3.Consortium or Federated Blockchain


The third type of blockchain is consortium blockchain that tries to remove the sole autonomy which gets vested in just
one entity as in private blockchain. In the case of consortium blockchain, unlike private blockchain, more than one
entity is present on the network. Since there is no single authority governing the control, it maintains decentralized
nature. There is a group of companies or representative individuals making decisions in the best interest of the whole
network. Such groups are called consortiums or federations; that’s why this blockchain got its name consortium or
federated blockchain. For example, let’s assume there is a consortium of 20 financial institutes on the blockchain
network. From these 20 institutes, the nodes will be pre-selected to make changes on the network.
These nodes have the authority to read or write transactions, and they can also allow or restrict participants on the
network. But none of the nodes alone can add a block to the Blockchain. To add a block, every single node has to
approve the block. The mechanism of reaching a decision to add a block is based on the voting system, also referred to
as the Proof of Vote mechanism. The purpose of this mechanism is to follow up on the selected nodes. Here every
node will need to vote in order to validate a block. The number of votes required will be pre-determined in order to
reach a decision of adding the block to the Blockchain. This means that it has been decided in the code that for fifteen
selected nodes, it might take ten nodes’ votes or even fifteen nodes’ votes to validate a block. By using the Proof of
Vote mechanism, the network helps to ensure that no one is misusing their power.
Let’s understand consortium blockchain by taking a real-world example of insurance claims. People have to deal with
a lot of paperwork when it comes to claiming insurance. Also, in specific scenarios, the whole process of claim
submission and approval takes a lot of time. Suppose a patient visits a hospital because of a health issue and needs
emergency surgery. But claiming the insurance and waiting for approval can delay his treatment, putting his life at
risk. If the hospital and insurance companies can unite in a Federated Blockchain network, where they can exchange
the information without any hassle, then it would be much easier to manage this process. This type of network also
ensures safety as they are dealing with sensitive, confidential records of the patient. Thus, the Federated blockchain
can unite these two institutions and give them the security they need. Not only healthcare but other insurances claims
can also be streamlined using Federated Blockchain.
Permissioned Blockchain: Both Private and Federal Blockchains are types of Permissioned blockchain. Permissioned
blockchain maintains an access control layer to allow certain actions to be performed only by certain identifiable
participants. On such Blockchain platforms, there is a need of special permissions to read, access, and write
information on them. The platform will allow anyone to join the Blockchain network after suitable verification of their
identity, and then permissions are allocated and designated to perform only certain activities on the network. The roles
of each participant who can access and contribute to the blockchain are defined.
Let’s understand permissioned blockchain through an example. Say a farmer in the village cultivates a product that he
ships to multiple markets across the globe. The supply chain involves multiple stakeholders like the customs
department who gives clearance for the product to enter their respective nation, shipping companies, and warehouse
operators who need to maintain the product within a specified temperature range. The farmer finalizes a particular
price and quantity for selling his produce to a buyer in India and another price and quantity to another buyer in
Australia. The information about the agreed prices between the farmer and buyers should not be revealed to other
entities involved, like the customs department, the shipping company, and the warehouse operator. They simply need
access to limited information, like quality specifications and quantity, to perform their necessary function in
supporting such deals. This is a perfect use case for the application of a permissioned blockchain, that can allow such
restricted implementation and limited permission to the various participants.
Permissioned Blockchain has many other applications like payments, KYC validation, escrow, insurance claims,
charity, music publishing, and much more. In a nutshell, the permissioned blockchain offers a secure business
environment with customization that allows wider industry adoption across multiple enterprises.
4.Hybrid Blockchain
The fourth type of Blockchain is Hybrid Blockchain, the blockchain which combines the best of both private and
public blockchains. Simply put, a hybrid blockchain provides controlled access (private) and freedom (public)
simultaneously. In other words, the hybrid blockchain lets organizations set up a private, permission-based system
alongside a public permissionless system.
With such a system, organizations can control -

• who can access what data on the blockchain,


• what data can be opened up publicly,
• what data needs to be kept confidential on the private network?
Fusing different features from private and public blockchains ensures that an organization can work with its
stakeholders in the best possible way.

• Like a consortium blockchain, a hybrid blockchain has the privacy benefits of a permissioned blockchain.
• But, unlike a consortium blockchain with multiple participants collectively helping to maintain the network, a
hybrid blockchain can have a single entity network administrator.

Hybrid Blockchain has features of both public and private blockchains


A transaction in a private network of a hybrid blockchain is usually verified within that network. But users can also
release it in the public blockchain to get it verified. Even though transactions and records in a hybrid blockchain are
kept private and not made public, they are always open for verifiability on the public blockchain whenever required.
In the hybrid blockchain, there are two different types of users/nodes based on the level of information that they
access:
(i) The first type of users/nodes are those who are part of the private blockchain and have all the control over the
blockchain and can decide the level of security permissions for a particular user.
(ii) And the other type of users/nodes are those who are part of the public blockchain and can just access the data
released on the blockchain.
Even though a set of individuals control the hybrid blockchain network, they cannot change the transactions’
immutability and security. They can only control which transactions are made public and which are not.
How can a user join the private network of a hybrid blockchain?
(i) A user is required to get permission to join the hybrid blockchain network and become a node on the private
network. Once he joins the network, he can fully participate in the blockchain’s activities, like the rights to do
transactions, view them, or even append or modify them.
(ii) The identity of the user is kept secret from other participating users to protect that user’s privacy. His identity is
only revealed to the party/user he is dealing with.
(iii) To ensure that the identification process of a user is done correctly, companies and organizations carry out KYC
(Know Your Customer) to make it work. Financial institutes, especially, need to handle the KYC process correctly as
they cannot allow the transaction to be carried out by a user who is anonymous or not entirely known to the
blockchain. Thus the hybrid blockchain has limited anonymity for the users who take part in the network, though
public anonymity is still maintained. This leads to an intersection of both the public and private systems.

Advantages of Hybrid Blockchain:


(i) The hybrid network offers all the critical features of a public blockchain, such as security, transparency,
immutability, and decentralization, but also restricts the ability to access transactions, view, or change transactions like
in a private blockchain. Moreover, not everyone can use the network, ensuring that confidential information doesn’t go
out of the network. Thus, a hybrid blockchain provides security and privacy but allows communication with third
parties.
(ii) Since a hybrid blockchain provides the ability to work in a closed ecosystem, thus, organizations don’t have to
worry about getting their information leaked or hacked.
(iii) Another benefit of using a hybrid blockchain is the low transaction cost as it requires few nodes to verify the
transactions. Therefore it also takes less time for the network to reach a consensus.

Here are a few examples where Hybrid Blockchain can be used:


(i) An area where hybrid blockchain technology can be implemented is the Hybrid IoT (Internet of Things). It is not
secure to manage the IoT on public blockchains as it will give hackers free access to data to map nodes and hack them.
But with a hybrid blockchain, the IoT devices can be placed in a private network with selective access to people who
need them. Conversely, the managing authority decides which aspects of the network should be made public
depending on what data needs to be shared.
(ii) The second application of hybrid blockchain is in government activities like voting, creating public identification
databases, automating acquisitions, providing social/ humanitarian assistance, etc. The hybrid blockchain offers the
government the necessary control and enables the public to access it. Totally private or public blockchains will not
work as they either hinder users’ access or reveal too much data. The hybrid blockchain can ensure that the
government stays in control of the data and, at the same time, gives access of data to the public. Thus, maintaining
transparency in government operations.
(iii) The third application of hybrid blockchain is in real estate. Companies can use a hybrid blockchain to run systems
privately but show certain information, such as listings, to the public.
(iv) Hybrid blockchains have applications in various other sectors like supply chains, banking, finance, trade,
enterprise services, etc.

which type of blockchain is suited for our business


How do we decide which type of blockchain is suited for our business requirements?
There are many factors to be considered. but the most basic ones are as follows:
First, how many copies of data should be maintained?
Only one copy and referred by only one entity, then a traditional database is sufficient. We don’t need a blockchain for
this.
If there are multiple copies of the database, which is owned or accessed by one or more entities, a permissioned
private blockchain might be suitable.
And the other important factor that should be taken into consideration is who can make changes to the data and who is
responsible for maintaining the integrity of the data. If it is a trusted group of entities, a permissioned private or
federate blockchain is what fits the situation best. If it is like anyone can make the changes, then permissionless public
blockchain like bitcoin is best.
Having answered these questions, these are only a few of basic questions that might help you to decide the type of
blockchain. The conclusion whether blockchain is a solution to your business problem or not, goes beyond these
factors and the decision is totally subjected and is best answered only from the perspective of respective stakeholders.

2.2: Hash Puzzle


Cryptographic Hash Puzzle:
Hash puzzle is a mathematical puzzle that miners must solve on blockchains in order to add their block to the chain.
Mining is the process by which new transactions are validated and added to the so-called ‘blockchain’. Those who are
participating in mining process are known as ‘miners’.
Let us consider an example
Let I tell three friends that I’m thinking of a number between one and 100, and I write that number on a piece of paper
and seal it in an envelope. My friends don’t have to guess the exact number; they just have to be the first person to
guess any number that is less than or equal to it. And there is no limit to how many guesses they get.
Let’s say I’m thinking of the number 19. If Friend A guesses 21, they lose because 21 > 19. If Friend B guesses 16 and
Friend C guesses 12, then they’ve both theoretically arrived at viable answers because of 16 < 19 and 12 < 19. There
is no “extra credit” for Friend B, even though B’s answer was closer to the target answer of 19.
Now imagine that I pose the “guess what number I’m thinking of” question, but I’m not asking just three friends, and
I’m not thinking of a number between 1 and 100. Rather, I’m asking millions of would-be miners, and I’m thinking of
a 64-digit hexadecimal number. Now you see that it’s going to be extremely hard to guess the right answer. If B and C
both answer simultaneously, then the system breaks down.
In Bitcoin terms, simultaneous answers occur frequently, but at the end of the day, there can only be one winning
answer. When multiple simultaneous answers are presented that are equal to or less than the target number, the Bitcoin
network will decide by a simple majority — 51% — which miner to honor.
Typically, it is the miner who has done the most work or, in other words, the one that verifies the most transactions.
The losing block then becomes an “orphan block.” Orphan blocks are those that are not added to the blockchain.
Miners who successfully solve the hash problem but haven’t verified the most transactions are not rewarded with
bitcoin.
The puzzle is essentially a word (list of characters — call it A), which represents the machine’s output, in order to
solve it your task is to find the the correct input (another word — call it B), such that when you put B into the machine
you will get A as an output.

Mining Process/ Solving Hash Puzzle:


Here is an example of such a number:
0000000000000000057fcc708cf0130d95e27c5819203e9f967ac56e4df598ee
The number above has 64 digits. That number consists of numbers (0-9)and letters of the alphabet (a-f) because
SHA256 produces hash output in hexadecimal format which consists of 64 bits containing 16 characters(0–9,a-f).
If we are mining Bitcoin, we do not need to calculate the total value of that 64-digit number (the hash).
In Bitcoin mining terms, that undisclosed number (the confidential information enclosed) in the envelope is called the
target hash.
During the process of mining, we cannot change Block ID, previous hash, data and we are left with Nonce and Hash
output in block. So, to solve hash puzzle, Miners make these guesses by randomly generating as many “nonces” as
possible, as quickly as possible. A nonce is short for “number only used once,” and the nonce is the key to generating
these 64-bit hexadecimal numbers. In Bitcoin mining, a nonce is 32 bits in size — much smaller than the hash, which
is 256 bits. The first miner whose nonce generates a hash that is less than or equal to the target hash is awarded credit
for completing that block and is awarded the spoils of 6.25 BTC.
When block 490163 was mined, he nonce that generated the “winning” hash was 731511405. The target hash is shown
on top. The term “Relayed by AntPool” refers to the fact that this particular block was completed by AntPool, one of
the more successful mining pools. Their contribution to the Bitcoin community is that they confirmed 1,768
transactions for this block.
Source: Blockchain.info
All target hashes begin with a string of leading zeroes. There is no minimum target, but there is a maximum target set
by the Bitcoin Protocol. No target can be greater than this number:
00000000ffff0000000000000000000000000000000000000000000000000000
The winning hash for a bitcoin miner is one that has at least the minimum number of leading zeroes defined by the
mining difficulty.
Here are some examples of randomized hashes and the criteria for whether they will lead to success for the miner:

Mining Pools:
The miner who discovers a solution to the puzzle first receives the mining rewards, and the probability that a
participant will be the one to discover the solution is equal to the proportion of the total mining power on the network.
Participants with a small percentage of the mining power stand a very small chance of discovering the next block on
their own. For instance, a mining card that one could purchase for a couple of thousand dollars would represent less
than 0.001% of the network’s mining power. With such a small chance at finding the next block, it could be a long
time before that miner finds a block, and the difficulty going up makes things even worse. The miner may never
recoup their investment. The answer to this problem is mining pools.
To find such a hash value, we have to get a fast mining rig with high computation power, or we have to join a mining
pool — a group of coin miners who combine their computing power and split the mined Bitcoin. A disproportionately
large number of blocks are mined by pools rather than by individual miners and the reward will be shared by all the
miners involved in the pool.

2.3: Extensibility of Blockchain Technology Concepts


Extensibility refers to the ability of a system to adapt and evolve over time.
The extensibility of blockchain technology allows for the development of new use cases beyond its original intent.
Extensibility is a critical factor in the ongoing success of blockchain technology.
Blockchain technology has a vast range of potential use cases, from supply chain management to identity verification
to voting systems. The extensibility of blockchain technology allows for the creation of new use cases that were
previously impossible. The potential use cases for blockchain technology continue to expand as the technology
evolves.
It is necessary to understand the new ideas separately and together.
Blockchain Technology concepts include public-key and private-key cryptography, peer-to peer file sharing,
distributed computing, network models, pseudonymity, blockchain ledgers, cryptocurrency protocols, and
cryptocurrency.
It is a required to understand these concepts in order to operate in the blockchain technology environment. When you
understand the concepts involved, it is not only possible to innovate blockchain-related solutions, but further, the
concepts are portable to other contexts.
This extensibility of blockchain-related concepts may be the source of the greatest impact of blockchain technology as
human agents understand these concepts and deploy them in every venue they can imagine.
One broad way of thinking about the use of blockchain concepts is applying them beyond the original context. The
extensibility of blockchain technology allows for the creation of new use cases and the evolution of existing ones.
However, there are significant challenges to be addressed, including scalability, privacy, governance, and
sustainability.
As blockchain technology continues to evolve, its potential use cases will continue to expand.
Some of the challenges to be addressed are
1. Smart Contracts
2. Interoperability
3. Scalability
4. Privacy
5. Governance
6. Sustainability

1.Smart Contracts:
Smart contracts are self-executing contracts with the terms of the agreement between buyer and seller being directly
written into lines of code. Smart contracts are a key innovation in blockchain technology, enabling the automation of
complex processes. Smart contracts have the potential to transform many industries, including financial services, real
estate, and supply chain management.
2.Scalability
• Scalability refers to the ability of a system to handle increasing amounts of work without impacting
performance.
• Scalability is a significant challenge for blockchain technology, which currently struggles with slow
transaction processing and high fees.
• Several solutions are being developed to address scalability, including sharding, layer 2 solutions, and
blockchain interoperability.

3.Interoperability
• Interoperability refers to the ability of different blockchain networks to communicate and work together
seamlessly.
• Interoperability is critical for the widespread adoption of blockchain technology.
• Several projects are underway to develop interoperability solutions, including Polkadot, Cosmos, and Ark.
4.Privacy
• Privacy is a critical concern for many blockchain use cases, particularly those involving sensitive data.
• Several privacy-focused blockchain projects, such as Monero and Zcash, have emerged to address this issue.
• Privacy-enhancing technologies, such as zero-knowledge proofs, are also being developed to improve privacy
on public blockchains.

5.Governance
• Governance refers to the systems and processes in place to manage and regulate a blockchain network.
• Effective governance is essential for the ongoing success of blockchain projects.
• Several governance models exist, including on-chain governance, off-chain governance, and hybrid models.

6.Sustainability:
• Sustainability refers to the ability of a blockchain network to operate over the long term.
• Blockchain networks require significant computing power and energy consumption, which can be a barrier to
sustainability.
• Several projects are exploring alternative consensus mechanisms, such as proof of stake, to improve
sustainability.
Some of the use cases are
1. Financial Services
2. Supply chain Management
3. Health Care
4. Identity Management
5. Voting Systems

1.Financial Services
• Blockchain technology has the potential to transform the financial services industry by enabling faster, more
secure, and more efficient transactions.
• Use cases for blockchain in financial services include cross-border payments, trade finance, and digital
identity.
• Several blockchain projects are focused on financial services, including Ripple, Stellar, and Corda.
2.Supply Chain Management
• Blockchain technology can improve supply chain management by increasing transparency and traceability,
reducing fraud and counterfeiting, and improving efficiency.
• Use cases for blockchain in supply chain management include tracking the origin and movement of goods,
verifying product authenticity, and reducing waste.
• Several blockchain projects are focused on supply chain management, including VeChain, Waltonchain, and
Ambrosus.

3.Healthcare
• Blockchain technology has the potential to transform the healthcare industry by improving patient data
management, reducing fraud, and increasing transparency.
• Use cases for blockchain in healthcare include patient data management, clinical trials, and drug supply chain
management.
• Several blockchain projects are focused on healthcare, including MedRec, Medicalchain, and FarmaTrust.

4.Identity Management
• Blockchain technology can improve identity management by reducing fraud, increasing security, and
improving privacy.
• Use cases for blockchain in identity management include digital identity, KYC/ AML compliance, and secure
authentication.
• Several blockchain projects are focused on identity management, including Civic, uPort, and SelfKey.

5.Voting Systems
• Blockchain technology can improve voting systems by increasing transparency, reducing fraud, and
improving accuracy.
• Use cases for blockchain in voting systems include online voting, secure and anonymous voting, and election
auditing.
• Several blockchain projects are focused on voting systems, including Follow My Vote, Agora, and Horizon
State.
2.4: Digital Identity Verification
Identity verification is the concept of proving that an identity is a real one. It’s about proving a person is who
they say they are and that it’s a real person behind the actions. In most places around the world, identity
verification uses data such as name, DOB and address to prove an identity is real.
Digital identity verification is the process of proving that an identity is real without ever having to meet
someone face-to-face. It confirms that a person is who they say they are and that the personal information
they have provided isn’t fake or stolen (identity fraud). Digital identity verification also helps ensure that it
is actually a person behind the screen and not fake identities — now much more easily created with the rise
of criminal technology.
Digital Identity Verification works by comparing the data that a person sends ( e.g., document such as a
passport or biometric data such as a picture of their face ) against a verified data set which can include
government records, credit references or even mobile data.
Digital identity verification speeds up the verification process, which is necessary for the fast pace of a
digital world in which the majority of our transactions take place online.
Customers nowadays expect and demand to be able to sign up for a product or service quickly and start
using it immediately. Delivering a smooth customer experience, however, has to be balanced with a secure
identity verification process that ensures a business is safeguarded and individuals are protected from
identity fraud. With so much of life now online, there is more data than ever before that can be misused if
not protected, so the identity verification process is crucial.
There are six common ways to verify someone’s identity online.
1. Biometric verification: This method uses unique biological traits of an individual, such as your
fingerprint, iris or face recognition. Certain smartphones use fingerprint or face recognition to verify
your identity.
2. Document verification: This method uses government-issued identification documents. These can be
passports, driver’s licenses or national identity cards.
3. Knowledge-based verification: By requesting information that only the person should know, such as
their mother’s maiden name, or addresses where they’ve lived, the system verifies a person’s identity.
4. Device authentication: This method involves verifying the device, such as a phone or computer, used
by the individual. Verification comes through the IP address or browser fingerprint.
5. Email verification: This one is prevalent due to emails’ broad acceptance across users. A system uses
personal credentials to set up the email account to verify the user for email verification.
6. Phone verification: Another typical verification process usually occurs in three steps. The customer
creates an account with their phone number and then the user receives a one-time passcode via an
SMS or phone call. Finally, the user submits the one-time passcode to obtain verification.
Digital Identity Verification can be done by Blockchain where we can control our identity without
depending on any central authority like UIDAI (Universal IDentification Authority of India) assigns a 12
bit unique number called Aadhar and controls one’s identity.
OneName, BitID, and BitHandle are examples of blockchain-based digital identity services.
OneName is decentralized digital identity verification system that runs on Namecoin protocol. OneName
helps solve the problem that 27- through 34-character Bitcoin addresses are cumbersome for human users.
Some other Bitcoin wallet services and exchanges, like Coinbase, have allowed Bitcoin to be sent to email
addresses for some time. The OneName service is a more secure solution.
With OneName, users can set up a more practical name (like a social media handle) to use for Bitcoin
transactions.
After a user is registered with OneName, performing bitcoin transactions is as easy as adding a plus sign to
your username (for example, +DeMirage99). OneName is an open source protocol built on the Namecoin
protocol that allows digital identity verification, rather than allowing centralized social media sites like
Facebook, LinkedIn, and Twitter to be the de facto identity verification platform, given that many websites
have opted to authenticate users with social media APIs.
BitID protocol allows users to login to websites with their Bitcoin address. Instead of “Login with
Facebook,” you can “Connect with Bitcoin” (your Bitcoin address). BitID is a decentralized authentication
protocol that takes advantage of Bitcoin wallets as a form of identification and QR codes for service or
platform access points.
BitID takes an already-verified identity that has been created by one online service, like a bank or bitcoin
exchange, and creates an ‘identity token’.
That token consists of two things: an actual Bitcoin address derived from the domain where the identity was
created, and eight bytes of code to signify what ID documents were used to verify it. The token is then
recorded on the blockchain.
This identity token can then be used by any other service using the BitID protocol. Anyone who wants to
verify that identity — another service or an individual — can simply scan a QR code to check that the
identity token exists.
Unlike other similar services, no detailed or identifying information is stored on the blockchain. BitID does
not require any permission to use, is completely decentralized, and protects users’ privacy from data mining
and theft.
Another proposed digital identity verification business is Bithandle, which was developed as a hackathon
project.
Bithandle offers short-handle registration, verification,and ecommerce service. As with Onename and BitID,
users can register an easy-to use handle — for instance, “Coinmaster” — that is linked to a wallet address
via a public or private real-life identity check and a Bitcoin blockchain transaction.
The service offers ongoing real-time digital identity verification and one-click auto-enabled ecommerce per
“Login with Bitcoin” website access.
An obvious problem with the mainstream adoption of Bitcoin is the unwieldy 32-character Bitcoin address,
or QR code, needed to send and receive funds.
Instead, Bithandle gives users the ability to link a short handle to a Bitcoin address, which is confirmed
initially with real-life identity and looked up in the blockchain on demand at any future moment.
Specifically, how Bithandle works is that in the digital identity registration process, participants register a
Bitcoin username, an easy-to-use handle that can then be used to “Login with Bitcoin” to websites. As
mentioned, this is similar to the ability to access websites by “Login with Facebook” or “Login with
Twitter” but automatically connects to a user’s Bitcoin address for proof of identity. When a user sets up a
Bithandle, his real-life identity is confirmed with Facebook, Twitter, LinkedIn, or other services, and this can
be posted publicly (like OneName) or not (as OneName does not allow), with the user’s Bithandle.

Later, for real-time digital identity verification, “Logging in with Bitcoin” means that a Bithandle is already
connected to a Bitcoin address, which securely facilitates ecommerce without the user having to register an
account and provide personal identity and financial details.
Bithandle thus helps streamline user interactions with websites in several ways.
1. First, websites do not have to maintain user account registries (“honeypot” risks for hacking).
2. Second, every user “Logging in with Bitcoin” is automatically enabled for one-click ecommerce
purchases.
3. Third, the Bithandle service can provide real-time blockchain lookups to confirm user digital identity
at any future time on demand — for example, to reauthorize a user for subsequent purchases.

2.5: Blockchain Neutrality


Cryptography experts and blockchain developers and architects point out the importance of designing the blockchain
industry with some of the same principles that have become baked into the Internet structure over time, like neutrality.
In the case of the Internet, net neutrality is the principle that Internet service providers should enable access to all
content and applications regardless of the source and without favoring or blocking particular products or websites.
The concept is similar for cryptocurrencies.
Bitcoin neutrality means the ability for all persons everywhere to be able to easily adopt Bitcoin. This means that
anyone can start using Bitcoin, in any and every culture, language, religion, and geography, political system, and
economic regime.
For example, the Islamic Bank of Bitcoin is investigating ways to conduct Sharia-compliant banking with Bitcoin.
A key point of Bitcoin neutrality is that the real target market for whom Bitcoin could be most useful is the
“unbanked,” individuals who do not have access to traditional banking services for any number of reasons, estimated
at 53 percent of the worldwide population.
Bitcoin neutrality means access for the unbanked and underbanked, which requires Bitcoin solutions that apply in all
low-tech environments, with features like SMS payment, paper wallets, and batched blockchain transactions.
Having neutrality-oriented, easy-to-use solutions for Bitcoin could trigger extremely fast uptake in underbanked
markets.
There are different SMS Bitcoin wallets and delivery mechanisms (like 37Coins96 and Coinapult, and projects like
Kipochi97 that are integrated with commonly used emerging-markets mobile finance platforms like M-Pesa.
Digital Divide of Bitcoin
The term digital divide has typically referred to the gap between those who have access to certain technologies and
those who do not. In the case of cryptocurrencies, if they are applied with the principles of neutrality, everyone
worldwide might start to have access. Thus, alternative currencies could be a helpful tool for bridging the digital
divide.
However, there is another tier of digital divide beyond access: know-how. A new digital divide could arise (and
arguably already has in some sense) between those who know how to operate securely on the Internet and those who
do not. The principles of neutrality should be extended such that appropriate mainstream tools make it possible for
anyone to operate anonymously (or rather pseudonymously), privately, and securely in all of their web-based
interactions and transactions.
2.6: Digital Art -Blockchain Attestation Services (Notary,
Intellectual Property Protection)
The term digital art in the blockchain industry is to refer to using the blockchain to register any form of IP (entirely
digital or representing something in the physical world) or conduct attestation services more generally, such as
contract notarization.
The term digital art is also used in the blockchain industry to mean online graphics, images photographs, or digitally
created artworks that are digital assets, and thus IP to protect.

Attestation Services:
Attestation services (declaring something to be true, such as asset ownership) are referred to as digital art. Attestation
services relies on the blockchain functionality of hashing and timestamping.

Hashing and Timestamping:


Hashing is running a computing algorithm over any content file (a document, a genome file, a GIF file, a video, etc.),
the result of which is a compressed string of alphanumeric characters that cannot be backcomputed into the original
content.
The hash represents the exact content of original file. Anytime the content needs to be reconfirmed, the same hash
algorithm is run over the file, and the hash signature will be the same if the file has not changed.
The hash is included as text in a blockchain transaction, which thus provides the secure timestamping function, when a
specific attestation transaction occurred. Via the hash, the original file content has essentially been encoded into the
blockchain.
Blockchain attestation services more generally comprise all manner of services related to document filing, storage, and
registry; notary services (validation); and IP protection.
Blockchain has the ability to use cryptographic hashes as a permanent and public way to record and store information,
and also to find it later with a block explorer. The core functionality is the ability to verify a digital asset via a public
general ledger.
There are several blockchain-based attestation services in different stages of development or proof of concept, such as
Proof of Existence, Virtual Notary, Bitnotar, Chronobit, and Pavilion.io.

Proof of Existence:
One of the first services to offer blockchain attestation is Proof of Existence.
Proof of Existence demonstrates document ownership without revealing the information it contains, and it provides
proof that a document was authored at a particular time. With this tool, the blockchain can be used to prove the
existence and exact contents of a document or other digital asset at a certain time.
Attorneys, clients, and public administrators could use the Proof of Existence blockchain functionality to prove the
existence of many documents including wills, deeds, powers of attorney, health caredirectives, promissory notes, the
satisfaction of a promissory note, and so on without disclosing the contents of the document.
With the blockchain timestamp feature, users can prove that a document (like a will) they will be presenting to a court
in the future is the same unaltered document that was presented to the blockchain at a prior point in time.

How does Proof of Existence Works?


1. present your document (or any file) to the service website;
2. you’re then prompted to “click or drag and drop your document here.” The site does not upload or copy the content
of the document but instead (on the client side) converts the contents to a cryptographic digest or hash. Thus, the hash
represents the exact contents of the document presented.
3. The cryptographic hash of the document is inserted into a transaction, and when the transaction is mined into a
block, the block timestamp becomes the document’s timestamp,and
4. using the hash the document’s content has essentially been encoded into the blockchain.
5. When the same document is presented again, the same marker will be created and therefore provide verification that
the documents are the same.
6. If, however, the document has changed in any way, the new marker will not match the previous marker.
This is how the system verifies the document.

Benefits:
1.Original documents are not stored on the blockchain, just their hash is stored, which is accessible by private key.
2. Whenever a proof of existence needs to be confirmed, the hash does not need to (and cannot) translate back into the
document. The document can be verified as unchanged, if the recomputed hash is the same as the original hash
registered in the blockchain.

Limitations:
There are some limitations to hashing-plus-timestamping blockchain attestation services.
1. a blockchain is not required for timestamping, because other third-party services provide this for free, whereas a
small transaction fee (to compensate miners) is required to post a digital asset attestation to the blockchain.
2. blockchain transaction confirmations are not immediate; the time the document was added to the blockchain is
recorded, not when the document was submitted.
3. timestamping does not prove ownership.
4. the hash might be less secure when you’re hashing very large documents (an 8-GB genome file, for example)
compared to small documents (a standard IOU contract)

Virtual Notary:
Virtual Notary is another project that similarly conceptualizes the need and fulfillment of blockchain attestation
services.
Like Proof of Existence, Virtual Notary does not store files but instead provides a certificate that attests to the file’s
contents at the moment of submission.
The service provides a certificate virtual notary-type service for many different “file types” such as documents, web
pages, Twitter feeds, stock prices, exchange rates, weather conditions, DNS entries, emailaddress verifications,
university affiliations, real estate values, statements and contracts,and random-number drawing.
Files can be in any format, including Microsoft Word, PDF, JPG, PNG, TXT, and PPT (Microsoft PowerPoint). The
site generates a certificate that can be downloaded from the site, and also offers the other side of the service —
examining existing certificates.
Virtual Notary’s aim is to provide a digital, neutral, dispassionate witness for recording online facts and conveying
them to third parties in a trustworthy manner.
Two other blockchain timestamp projects are Bitnotar and Chronobit. Two other virtual notary projects are Blocksign
and btcluck.
A similar blockchain-based project for contract signing is Pavilion.io, which provides the service much cheaper than
Adobe EchoSign or DocuSign; contracts are free to send and only one mBTC to sign.

Monegraph:
One digital-art protection project built and intended as a proof of concept using the blockchain ledger Bitcoin is
Monegraph,
Using this (currently free) application, individuals can facilitate the monetization of their online graphics — digital
media they have already created and posted on the Web — by registering their assets. Just as Bitcoin verifies currency
ownership, Monegraph verifies property ownership;
This an example of the smart property application of the blockchain. Monegraph could be a complementary service or
feature for stock photo image and graphic repository websites like Shutterstock or Getty Images, possibly adding
future functionality related to image use enforcement and tracking.

Working of Monegraph:
Monegraph works in a two-step process using Twitter, Namecoin, and Monegraph. Namecoin is used because it is an
altcoin that can be used to verify DNS registrations in an automated, decentralized way; any similar DNS confirmation
service could be used.
1. To stake the claim, the user goes to http://www.monegraph.com/, gives it permission to sign into Twitter account
(via the standardized Twitter API OAuth token),
2. supply the URL of the graphic, upon which Monegraph automatically tweets a link to that image in the correct
format.
3. To record the title, after Monegraph tweets the link to the image, it provides a block of code for the user to copy and
paste into the Namecoin client.
4. The user initiates a new transaction in the Namecoin wallet and adds the block of code as the key and value in the
Namecoin transaction (you can see the transaction here: http://bit.ly/monegraph_verification).
5. Only one copy of a digital image can ever have a valid Monegraph signature. Monegraph images are just ordinary
image files, so they can be duplicated and distributed like any other images, but only the original file will pass
validation against the Monegraph system.
Ascribe:
A related digital art and copyright protection project is Ascribe, which is aimed at providing an underlying
infrastructure for IP registry.
The company is building an “ownership layer” for digital property in the form of a service to register and transfer
copyright. Although existing copyright law offers creators protection against infringement and the right to
commercialize, there is no simple, global interface to register, license, and transfer copyright.
Working of Ascribe:
1. The Ascribe service registers a digital work with the service hashes and timestamping it onto the blockchain. An
earlier step in the registration process uses machine learning to detect and resolve any prior-art challenges.
2. Ownership rights can then be transferred, which enables secondary markets for digital IP.
The service handles digital fine art, photos, logos, music, books, blog posts, tweets, 3D CAD files, and more. Users
need no prior knowledge of the intricacies of the blockchain, copyright law, or machine learning to benefit from the
service.
The bulk of Ascribe’s users are marketplaces and white-label web services that use Ascribe in the background, though
individual users can use the site directly, as well.

2.7: Blockchain Environment-Adding Metamask Wallet


Metamask wallet: To install metamask , go to vertical 3 dots on right hand side of browser tab, then go to
extensions -> manage extensions
Click on 3 horizontal lines on left side

Click on Open Chrome Web Store. In search the store type metamask wallet and click on it. The following will get
displayed.

Click on it and click add to chrome, and then add extension.

Now agree the terms and click on create a new wallet, and then I agree.

Set password and proceed


Click on secure my wallet and then reveal recovery phrase

then it will reveal and when you click on next, it will ask to confirm recovery phrase

Now your wallet is created successfully


2.7: Blockchain Environment -Smart Contracts
In 1996, Nick Szabo described a smart contract as “ a set of promises specified in digital form including protocols
within which the parties perform on these promises.”

Smart contracts are the self-executing programs that are stored on Blockchain and run when predefined conditions are
met.
Smart contracts automatically execute transactions if certain conditions are met without requiring the help of a third
party to manage or approve the transaction.
For example, there is a deal that is made with two friends Alice and Bob. Alice lend 1000rs from Bob and has
promised to return in the next month. They have created a smart contract to automate the return of the payment.
So, the next month, 1000rs will be automatically get deducted from the Alice account and it will be paid to Bob. None
of them have to interfere in the returning process. It will be done automatically.

Let us consider another scenario, in which Dave is the owner of the car and he wants to sell it. So, he creates a smart
contract. With his private key, he signs and deploy it in the network which is broadcasted to every peer in the network.
Then this car along with the key will be put in the smart garage. The details will be shared with the network, where
every peer in the network will know that the owner is Dave.

Now Claire login to the system with her private key. She accesses the smart contract to pay the money. Now the
money will be received by the signified person of the contract, the owner name will be changed from Dave to Claire
and is broadcasted to the network, so that evry node will know the current owner is Claire.

Working of Smart Contracts:

• Identify requirement for agreement


• Identify the conditions for agreement- what to do if this happens? what to do if that happens? (if-then)
• code the business logic for the inputs we are expecting, the outputs to be returned, on what condition this
smart contract will execute and so on.
• Once the code is ready it is encrypted and sent to Blockchain network or the distributed ledgers for execution.
• When the contract arrives on the network, each node in the network will come to an agreement on the
execution of the contract. After such an agreement is established by networks then manipulation is not
possible.
Benefits of Smart Contracts:

• Automated: Manual interference is not required.


• Direct- No intermediaries: Smart contracts allows the parties to enter the agreement without the
intermediaries.
• Faster settlements: Since settlements are done digitally, it happens instantly and will be faster
• Lower cost: As it requires only less human intervention, and it reduces the cost.
• Transparency: It creates an environment of trust as the conditions in the agreement are visible to all nodes in
the network.
• Security: The control over the execution of smart contract codes is distributed over the network, it eliminates
the risk of manipulation.

2.7: Blockchain Environment- softwares to be installed and


Launching Blockchain Server
Setting up Blockchain environment:

We can write smart contracts in two ways

1. Using Remix IDE (Integrated Development Environment)

2. Using VS Code editor

Softwares to be installed:

1. Install Vs code and add solidity extension

2. Add chrome extension Metamask wallet — It is a free and secure browser extension that allows web applications to read
and interact with the ethereum blockchain.

3. Install node.js (LTS version) — node.js is javascript but on server side. It is used as development tool for blockchain.
When you install node.js, it comes with npm (node package manager) which allows you to easily install tool frameworks
and libraries from the command line. Go to run->cmd->node -v displays node.js version

4. Install Truffle — Truffle is a framework for writing smart contract, tests them and deploy them. It mainly target the
solidity programming language which is the most popular programming language for smart contract. Truffle is mostly
used for the ethereum blockchain. Truffle has a built-in compiler for solidity and also has a built-in development
blockchain called Ganache.

To install truffle, type in command prompt

$npm install -g truffle (here -g installs truffle globally.)

$truffle version

5. Install Ganache — Click on QuickStart Ethereum (Launching Blockchain network). If you save this random name will
be generated for workspace rather than Quickstart.
6.

This is test network. Check the port in RPC Server configuration., which is usually 7545.

Gas — how much computing power this transaction needed

Gas will be calculated based on transaction request. Based on GAs, transaction fee will be charged. In real-time scenario,
it might take 15–20 min for mining process.

Click on the key symbol of an account to see account information.

This private key is used to make transactions by importing it in metamask wallet.

By clicking on the blocks, we can see that there is block0 which is called genesis block and it is empty because of no
transactions made. By clicking on block 0, we can see a unique hash value.

2.7: Blockchain Environment — Connecting Ganache to Metamask


Wallet
Connecting Ganache to Metamask Wallet (Cryptowallet):

To connect with full node which is Blockchain server, we need a half node called cryptowallet.

Once metamask wallet is created, click on extensions symbol on top right corner and pin metamask.
click on it to open. Once opened, click on down arrow symbol beside ethereum mainnet.

Click on Add network

Scroll down and click on Add a network manually


Click on save. Then network will be added successfully. After that click on switch to Ganache to make transactions.

The page gets displayed as follows:

Import an account from Ganache and make transactions between Account1 and Account2:

Go to Ganache and copy the private key of account to import

Now to make transactions, import an account from Ganache as shown below


paste the private key and click on Import

Now click on send to make transactions and then transfer between my accounts

click on Account1

Enter the amount to be transferred


Click on Next and then confirm

We can see the change here, 10ETH in Account1 and remaining amount in Account2. In account2 it is 89.99… rather

than being 90, because a fraction of amount will be deducted for miner fee.

Now goto ganache and click on Blocks on top row. Now you can see that Block 1 has been added tothe blockchain

Click on Block1 to view the details of it.

click on value transfer to view the amount transferred etc.


you can see here, account1 is debited by 10 ETH and balance is 90ETH.

2.7: Blockchain Environment- Creating a smart contract in Remix


IDE
Solidity is an object-oriented programming language designed for writing smart contracts. It is used for implementing
smart contracts on various blockchain platforms, mostly for Ethereum using the Ethereum Virtual Machine (EVM).
Solidity Compiler will convert the program into byte code which can be executed by EVM and then deployed on to a
Blockchain network.
Ethereum is the second largest cryptocurrency platform by market behind Bitcoin.
We can create a simple Smart Contract that allows the user to deposit and withdraw Ethers from the Contract.
Remix IDE
Remix IDE is an open-source Integrated Development Environment (IDE) for Solidity. Remix IDE allows us to write,
compile, test, and deploy our Smart Contract directly on the Internet Browser. Remix Online IDE can be accessed here.

File Explorer — This is an option available on Remix IDE to handle various files associated to a Smart Contract.
When accessed for the first time, the IDE will pre-generate files and directories.
Step1:
To create a new Solidity file, Right-click the “contracts” directory and click on “New File”. Then, enter the filename,
say “demo.sol”.
Step2: Writing the Smart Contract

//SPDX-License-Identifier: MIT
pragma solidity 0.8.18;

contract demo
{
string _msg; //state variable

//reading data
function takeInput(string memory a) public
{
_msg=a;
}
//displaying data
function giveOutput() public view returns(string memory)
{
return (_msg);
}
}

SPDX-License-Identifier is a license Identifier syntax. It is the essential statement in any solidity smart contract because
without it, smart contract will likely throw an error.

//SPDX-License-Identifier: MIT

In Solidity, we need to declare the language version to be used for the compiler. This can be done by using
the pragma keyword.

pragma solidity 0.8.18;

This line of code tells the compiler to use solidity version 0.8.18. We can also input a range of versions to be used.

pragma solidity >=0.4.0 <0.9.0;

This will tell the compiler to use version 0.4.0 as the minimum and 0.9.0 as the maximum.
Defining Contract
Defining a contract in Solidity is similar to defining a class in other programming languages. To define a contract we
can use the contract keyword followed by the name of our contract.

Let’s add variables inside our contract. Solidity’s Data Types can be found here. Here, we are using string to store the
message in the Smart Contract.
To declare a variable in Solidity, we first write the data type and then the variable name. Optionally, we can add an
access modifier such as private and public before the variable name.

Create a function
To create a function, the structure of functions in solidity is

function <<functionName>>(<<parameterName>> <<parameterType>>) <<functionType>> returns(<<returnType>>) {


}
Function’s visibility types :
• public: can be called by anyone
• private: can only be called by functions inside the contract
• external: can be called by anyone except functions inside the contract
• internal: can only be called by functions inside the contract and its subclass
Function’s access types :
• view: the function only reads from the blockchain
• pure: the function does not reads or write to the blockchain
• payable: the function accepts payment when its called
We are creating 2 functions
1. “takeInput” function with public as the function type — this function will take input from the user.
2. “giveOutput” function with public and view as the function type and string as the return type.— this
function will return output from the user.

Step3: Compiling and running the smart contract


To compile the smart contract, we can click the Solidity Icon to display the Solidity Compiler Tab. In this tab, we can
specify the compiler version to be used. Then, we can click on compile button to compile the code. The shortcut for
compiling is Ctrl + S.

When a compilation for a Solidity file succeeds, Remix creates three JSON files for each compiled contract.

Then we can click on the Ethereum logo to view the Deploy and Run Transactions Tab. In this tab, we can choose the
environment where our smart contract will be deployed, Use the generated accounts which contain test Ethers, Set the
gas limit for transactions, Set the amount of ether to be transferred for the transaction, Set the contract to be used, and
then click on Deploy button.
After the contract is deployed. We can interact with the contract in the Deployed Contracts Section.

Now enter a input string and click on takeInput button. And then click on giveOutput button to see the output.

2.7: Blockchain Environment- Migrate a smart contract into Ganache using Truffle
Build a smart contract
Step 1: With Ganache running behind, open new terminal, and run the commands below:

$ cd Desktop
$ mkdir DemoSmartContract
$ cd DemoSmartContract
$ truffle init
1. /contracts: store original codes of the smart contract. We will place our demo.sol file here.
2. /migrations: deploy the smart contract in the “contracts” folder.
3. /test: test codes for your smart contract, support both JavaScript and Solidity.
4. truffle-config.js: configuration document for windows user.
Oen VS Code editor and open folder on desktop with name “DemoSmartContract”.

Step 2: Create “demo” contract.


There are two ways to create a new contract:
1. Directly place “demo.sol” file under “contracts” folder.
2. run command in terminal

$ truffle create contract demo

It automatically updates in Vscode editor

Copy the following code into “demo.sol”:

//SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
contract demo
{
string _msg; //state variable

//reading data
function takeInput(string memory a) public
{
_msg=a;
}

//displaying data
function giveOutput() public view returns(string memory)
{
return (_msg);
}
}

Step 3: Compile smart contract.


Modify truffle-config.js as shown below:(line no:67–71 :uncomment, change port number to 7545, line no. 109: change
version to 0.8.18)

Now compile using following command

$ truffle compile

This compiles the original code into Ethereum bytecode. If everything goes well, it will create .json file
under build/contracts folder. This json document is called as “artifact”. It contains abi (application byte code) which is
used to deploy smart contract — can see in line no.3. We can also see byte code and deployed byte code at lines 33–34.

Step 4: Deploy Smartcontract.


Step 4.1: Create a js file under migrations, name it “1_deploy_contract.js”.

const demo=artifacts.require ("./demo.sol");


module.exports = function(deployer) {
deployer.deploy(demo);
}

module.exports function is called automatically by truffle.


Step 4.3: Run the following command: (make sure ganache is runnning)

$ truffle migrate
While migrating using truffle on Ganache, a block will be created.
Before migrating, only block0 exists in Ganache. After migration, block1 is created.

On clicking transaction

Click on Contract Creation

Block will be holding tranction data which is in encrypted form. To connect with contract, we need and contract
address.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy