0% found this document useful (0 votes)
31 views

Unit Ii

The document discusses the concept of extensibility in blockchain technology. It can adapt and evolve over time, allowing for new use cases beyond its original intent. This extensibility is critical to blockchain's success. The document outlines some challenges and potential solutions like smart contracts, scalability, and privacy.

Uploaded by

shashikumard29
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Unit Ii

The document discusses the concept of extensibility in blockchain technology. It can adapt and evolve over time, allowing for new use cases beyond its original intent. This extensibility is critical to blockchain's success. The document outlines some challenges and potential solutions like smart contracts, scalability, and privacy.

Uploaded by

shashikumard29
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

UNIT- II

EXTENSIBILITY OF BLOCKCHAIN 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 Smart Contracts, Interoperability
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 Gps-sis
5. Governance
6. Sustainability
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.
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.
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.
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.
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.
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
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.
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.
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.

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( Anti-Money
Laundering) compliance, and secure authentication.
Several blockchain projects are focused on identity management, including Civic, uPort, and SelfKey.

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.
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 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.

bob
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.

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.

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: Pv-bpc
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.

“Last documents registered” digest from Proof of Existence


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 fulfilment 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, email
address 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.

BLOCKCHAIN ENVIRONMENT Dns-prc-cid


The term "blockchain environment" typically refers to the technical infrastructure or ecosystem in which
blockchain technology operates. A blockchain environment encompasses various elements and components
that facilitate the functioning of a blockchain network. Here are some key aspects of a blockchain
environment:
1. Distributed Ledger Technology (DLT): Blockchain is a type of distributed ledger technology. It's a
decentralized database that maintains a continuously growing list of records (blocks) linked and
secured using cryptography.
2. Nodes and Network: A blockchain network consists of nodes, which are individual computers or
devices participating in the network. These nodes maintain a copy of the entire blockchain and
validate transactions.
3. Consensus Mechanisms: To achieve agreement on the state of the blockchain, consensus
mechanisms are used. Popular ones include Proof of Work (PoW), Proof of Stake (PoS), and
variations like Delegated Proof of Stake (DPoS), among others.
4. Smart Contracts: These are self-executing contracts with the terms of the agreement between
parties directly written into code. They automatically enforce and execute predefined conditions
when specific criteria are met.
5. Cryptocurrencies or Tokens: Many blockchains have their native digital currencies or tokens. For
instance, Bitcoin (BTC) for the Bitcoin blockchain or Ether (ETH) for Ethereum.
6. Privacy and Security Measures: Cryptography ensures security by encrypting data and enabling
secure transactions. Different blockchains have varying degrees of privacy features, some providing
anonymity, while others focus on transparency.
7. Development Tools and Frameworks: Software development kits (SDKs), APIs, and various
development tools are available for building decentralized applications (dApps) and interacting with
the blockchain.
8. Consensus and Governance Models: Blockchains often have unique governance models to make
decisions about protocol upgrades, changes, or community governance. These models differ from
one blockchain to another.
9. Interoperability: Efforts to enable different blockchains to communicate and interact seamlessly to
facilitate data and asset transfer between them.
10. Regulatory Considerations: The legal and regulatory landscape surrounding blockchain
technology, cryptocurrencies, and decentralized applications varies in different regions and
countries.(Binance application India is blocked)

Blockchain environments are continually evolving with new technologies, consensus algorithms, scalability
solutions, and advancements in decentralized finance (DeFi), non-fungible tokens (NFTs), and other use
cases beyond cryptocurrencies. They aim to address challenges such as scalability, interoperability, and
sustainability while exploring new applications across industries beyond finance, including supply chain,
healthcare, and voting systems, among others.

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

skate child field bachelor pelican office clock possible amused order globe receive
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
Smart Contracts
Blockchain Coding Environment:
Smart Contract:
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 broad caste d 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 every node will know the current owner is Claire.
Working of Smart Contracts:

1. Identify requirement for agreement


2. Identify the conditions for agreement- what to do if this happens? what to do if
that happens? (if-then)
3. 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.
4. Once the code is ready it is encrypted and sent to Blockchain network or the
distributed ledgers for execution.
5. 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:


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

Software’s 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.

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.
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.

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.

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.
Open 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 transaction data which is in encrypted form. To connect with
contract, we need and contract address.

You might also like