0% found this document useful (0 votes)
10 views30 pages

UNIT - 4 Notes

Uploaded by

pavincletus123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views30 pages

UNIT - 4 Notes

Uploaded by

pavincletus123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

SCHOOLOFCOMPUTING

DEPARTMENTOFCOMPUTERSCIENCEANDENGINEERING

UNIT– IV-CRYPTOCURRENCY TECHNOLOGIES –SCSA 3059


UNIT- 4

ETHEREUM AND SOLIDITY

Alternative approaches to mining and consensus - Bitcoin and anonymity -


Overview of Altcoins - Overview of Ethereum - Programming smart contracts on
Ethereum - Solidity Language - Cryptocurrencies & the real world: Smart
property, data feeds, and public randomness - Applications of cryptocurrencies
and blockchains

.
ALTERNATE APPROACHES TO CONSENSUS AND MINING
Some alternate approaches that might have emerged or gained prominence:
1. Delegated Proof of Stake (DPoS): DPoS is a variation of PoS where token
holders vote for a limited number of delegates who are responsible for
validating transactions and creating new blocks. These delegates are chosen
based on the number of votes they receive. DPoS aims to increase scalability
by reducing the number of validators compared to traditional PoS systems.
In a DPoS system, token holders in the network have the
power to elect a limited number of delegates who will be responsible for
validating transactions and creating new blocks on behalf of the entire
network. These delegates, also known as "witnesses" or "block producers,"
are chosen through a voting process based on the number of tokens they hold
or have been delegated to them.
The DPoS process typically works as follows:
a. Voting: Token holders in the network vote for their preferred
delegates. The weight of their votes is determined by the number of
tokens they hold or have staked.
b. Delegates Selection: The delegates with the highest number of votes
become the active block producers. The number of active delegates is
limited to a fixed number, which helps maintain network efficiency
and decentralization.
c. Block Production: The active delegates take turns in producing new
blocks in a round-robin manner. Each delegate gets a chance to
produce a block in a specific order, and this rotation ensures that the
responsibility of block production is distributed fairly among the
chosen delegates.
d. Block Verification: After a delegate produces a block, it is
broadcasted to the network. Other delegates and participants in the
network then verify the validity of the block and the transactions it
contains.
e. Consensus: If the majority of the delegates agree that the block is
valid, it is added to the blockchain. Consensus is achieved through a
combination of voting and the reputation of the delegates.

2. Proof of Authority (PoA): PoA relies on a fixed set of approved validators,


who are typically known and trusted entities. Validators take turns to create
blocks, and their authority to validate transactions is derived from their
identity or reputation. PoA is often considered more centralized but can be
suitable for private or consortium blockchains.
In a PoA system, the validators, also known as "authorities" or
"block signers," are pre-selected and known entities with a reputation for
reliability and trustworthiness. These validators have the authority to create
blocks and validate transactions based on their identity or approval by a
higher authority.
The PoA process typically works as follows:
a. Validator Selection: A central authority or the existing validator set
selects the approved validators. The selection is based on factors such as
reputation, identity verification, or stake in the network.
b. Block Creation: Validators take turns to create blocks in a
predetermined order. Each validator has a designated time slot during
which they are responsible for proposing a block containing valid
transactions.
c. Transaction Verification: After a validator creates a block, they sign
it digitally, attesting that the block and its transactions are valid. Other
validators in the network then verify the signature and the validity of the
proposed block.
d. Consensus: If the majority of validators agree that the block is valid,
it is added to the blockchain. Consensus is achieved through the agreement
of trusted validators rather than through a competition as in PoW or based
on the amount of stake as in PoS.

3. Proof of Space (PoSpace): PoSpace requires participants to dedicate storage


space on their devices to solve cryptographic challenges. The larger the
storage space, the more likely a participant is to mine a new block. PoSpace
aims to be more energy-efficient than PoW and can be useful for certain
applications.
In PoSpace, miners, also known as "provers," demonstrate
that they have allocated a certain amount of storage space to the network,
and this allocated space is used as proof to mine new blocks and participate
in the consensus process. The larger the storage space dedicated by a
participant, the higher the chance they have to be selected as the block
producer.
The PoSpace process typically involves the following steps:
a. Storage Allocation: Miners preallocate a specific amount of their storage
space to participate in the PoSpace mining process.
b. Initialization: The miner creates a plot file, which is a data structure
containing hashes derived from the initial storage allocation. The plot file is
used to generate proofs efficiently.
c. Challenge: The network issues a challenge, which is usually a random value
or hash, to the miners.
d. Proof Generation: Miners search their plot files to find a solution to the
challenge. The proof of space is generated by providing the required hash
from the plot file in response to the challenge.
e. Verification: Other participants in the network verify the proof of space to
ensure that the miner has genuinely allocated the claimed storage space and
has not cheated in generating the proof.
f. Block Creation: Once a valid proof is presented and accepted by the
network, the miner becomes eligible to create a new block and add it to the
blockchain.

4. Proof of Burn (PoB): In PoB, participants burn or destroy a certain amount


of cryptocurrency to demonstrate their commitment to the network. Burning
tokens makes it costly to participate, and participants are rewarded based on
the amount they burn. PoB acts as a mechanism to distribute tokens fairly
and encourages long-term investment.
In PoB, participants prove their commitment to the
network by "burning" or permanently destroying a certain amount of
cryptocurrency or tokens. Burning tokens means sending them to an address
from which they cannot be spent or retrieved. The act of burning tokens
serves as proof that the participant is willing to incur a cost to participate in
the network.
The PoB process typically works as follows:
a. Token Burning: Participants initiate the PoB process by sending a specific
number of tokens to a "burn address" from which they cannot be spent or
moved.
b. Block Creation: Once tokens are burned, the participant becomes eligible to
mine or validate transactions. The chance to create a new block is usually
proportional to the number of tokens burned, meaning the more tokens
burned, the higher the likelihood of being selected to create a block.
c. Transaction Validation: The selected participants (block creators) validate
transactions and add them to the new block they are creating.
d. Consensus: Other participants in the network verify the validity of the
newly created block, including the proof of burn, before accepting it as part
of the blockchain. Consensus is achieved when the majority of participants
agree on the validity of the block.
e. Block Reward: As a reward for their contribution, the block creator receives
transaction fees from the included transactions or may receive newly minted
tokens, depending on the blockchain's reward mechanism.

5. Proof of Activity (PoAcy): PoAcy combines PoW and PoS elements. It


requires participants to prove their ownership of a certain number of tokens
(PoS), but they also need to perform some computational work (PoW) to
create a new block. This approach aims to balance security and energy
efficiency.
6. Directed Acyclic Graph (DAG) Consensus: Directed Acyclic Graph
(DAG) Consensus is a unique approach to achieving consensus in
blockchain networks. Instead of using traditional linear blockchains, DAG-
based systems use a graph-like structure to record and validate transactions.
In a DAG, each transaction references one or more previous transactions,
forming a directed graph with no cycles (acyclic).

7. Proof of Reputation (PoR): In a PoR system, participants are assigned


reputation scores based on their history of activities within the network.
These activities could include validating transactions, contributing to the
network's security, participating in governance, or providing valuable
services to the ecosystem.
The PoR process typically involves the following steps:
a. Reputation Assessment: Participants' actions and contributions are
evaluated and assigned a reputation score based on their behavior and past
performance within the network. This assessment can be performed by the
consensus protocol or through a reputation system managed by the
community.
b. Consensus Role: Participants with higher reputation scores are given a
greater say in the consensus process. They might be assigned the role of
block proposers or have more weight in validating transactions.
c. Block Validation: When a block is proposed, it is verified and accepted by
the participants with the highest reputation scores. Their approval lends
credibility to the proposed block and helps determine its acceptance by the
network.
d. Incentives and Rewards: Participants may be incentivized to maintain and
improve their reputation scores by receiving rewards for their active and
trustworthy participation in the network.

Bitcoin and anonymity :


While Bitcoin transactions are recorded on the blockchain and are publicly
visible, the identities of the parties involved in these transactions are not
directly tied to their wallet addresses. This has led to the perception that
Bitcoin transactions offer a certain level of anonymity. However, it's
important to note that Bitcoin transactions are actually pseudonymous rather
than fully anonymous. Here's what this means:

1. Pseudonymous Transactions: Bitcoin transactions are associated


with alphanumeric addresses (wallet addresses) rather than real-world
identities. This provides a level of privacy as transactions are not
directly tied to personal information. However, all transactions are
recorded on the public blockchain, and these addresses can be linked
to certain identities through various means, such as analyzing
transaction patterns or IP addresses.

2. Transaction Traceability: The blockchain is a transparent and


immutable ledger, which means that every transaction is permanently
recorded and traceable. This enables anyone to view the history of
transactions associated with a particular wallet address. Analyzing the
blockchain and transaction flows can potentially reveal patterns and
connections between different addresses.
3. Deanonymization Risks: While Bitcoin transactions do not explicitly
reveal personal information, various techniques and analyses can be
used to attempt to link wallet addresses to real-world identities. Chain
analysis, data correlation, and metadata leaks can potentially expose
users' identities, especially if the user's privacy practices are not well-
implemented.

4. Privacy Enhancements: Over time, developers have worked on


improving the privacy features of Bitcoin. Techniques like CoinJoin
and Schnorr signatures are designed to enhance transaction privacy by
mixing multiple transactions together and aggregating signature data,
respectively. Additionally, other cryptocurrencies known as privacy
coins (e.g., Monero, Zcash) have been developed with a primary focus
on enhanced privacy features.

In summary, Bitcoin transactions offer a certain degree of pseudonymity, but


they are not completely anonymous. Users looking for stronger privacy
should be cautious and consider using additional privacy-focused tools and
practices. It's also important to note that the regulatory landscape
surrounding cryptocurrencies is evolving, and authorities may require
exchanges and service providers to adhere to anti-money laundering (AML)
and know-your-customer (KYC) regulations, which can impact the level of
privacy associated with cryptocurrency transactions.
What Is Altcoin?
Altcoins are generally defined as all cryptocurrencies
other than Bitcoin (BTC). However, some people consider altcoins to be all
crytocurrencies other than Bitcoin and Ethereum (ETH) because most
cryptocurrencies are forked from one of the two. Some altcoins use different
consensus mechanisms to validate transactions and open new blocks, or
attempt to distinguish themselves from Bitcoin and Ethereum by providing
new or additional capabilities or purposes.
Most altcoins are designed and released by developers who
have a different vision or use for their tokens or cryptocurrency.
"Altcoin" is a combination of the two words "alternative"
and "coin." It is generally used to include all cryptocurrencies and tokens
that are not Bitcoin. Many are forks—a splitting of a blockchain that is not
compatible with the original chain—from Bitcoin and Ethereum. These
forks generally have more than one reason for occurring.
1. Payment Token
As the name implies, payment tokens are designed to be used
as currency—to exchange value between parties. Bitcoin is the prime
example of a payment token.
2. Stable coins
Cryptocurrency trading and use have been marked
by volatility since launch. Stable coins aim to reduce this overall volatility
by pegging their value to a basket of goods, such as fiat currencies, precious
metals, or other cryptocurrencies. The basket is meant to act as a reserve to
redeem holders if the cryptocurrency fails or faces problems.
3. Security Tokens
Security tokens are tokenized assets offered on stock
markets. Tokenization is the transfer of value from an asset to a token, which
is then made available to investors. Any asset can be tokenized, such as real
estate or stocks. For this to work, the asset must be secured and held.
Otherwise, the tokens are worthless because they wouldn't represent
anything. Security tokens are regulated by the Securities and Exchange
Commission because they are designed to act as securities.
4. Utility Tokens
Utility tokens are used to provide services within a network.
For example, they might be used to purchase services, pay network fees, or
redeem rewards. File coin, which is used to buy storage space on a network
and secure the information, is an example of a utility token.
Ether (ETH) is also a utility token. It is designed to be used in
the Ethereum blockchain and virtual machine to pay for transactions.
5. Meme Coins
As their name suggests, meme coins are inspired by a joke or
a silly take on other well-known cryptocurrencies. They typically gain
popularity in a short period of time, often hyped online by prominent
influencers or investors attempting to exploit short-term gains.
Many refer to the sharp run-up in this type of altcoins during April and May
2021 as "meme coin season," with hundreds of these cryptocurrencies
posting enormous percentage gains based on pure speculation.
6. Governance Tokens
Governance tokens allow holders certain rights within a
blockchain, such as voting for changes to protocols or having a say in
decisions of a decentralized autonomous organization (DAO). Because they
are generally native to a private blockchain and used for blockchain
purposes, they are utility tokens but have come to be accepted as a separate
type because of their purpose.

Pros and Cons of Altcoins


Pros :
 Improve upon another cryptocurrency's weaknesses: Altcoins are
"improved versions" of the cryptocurrency they derived from because they
aim to plug perceived shortcomings.
 Higher survivability: Altcoins with more utility have a better chance of
surviving because they have uses, such as Ethereum’s ether.
 Thousands to choose from: Investors can choose from a wide variety of
altcoins that perform different functions in the crypto economy.

Cons:
 Lower popularity and smaller market cap: Altcoins have a smaller
investment market compared to Bitcoin. Bitcoin has generally hovered
around 40% of the global cryptocurrency market since May of 2021.8
 Less liquid than Bitcoin: The altcoin market is characterized by fewer
investors and less activity, resulting in thin liquidity.
 Difficult to determine use cases: It is not always easy to distinguish
between different altcoins and their respective use cases, making investment
decisions even more complicated and confusing.
 Many altcoins are scams or lost developer and community interest:
There are several "dead" altcoins that ended up sinking investor dollars.
Ethereum definition
Ethereum is a decentralized blockchain network powered by the Ether token that
enables users to make transactions, earn interest on their holdings through staking,
use and store nonfungible tokens (NFTs), trade cryptocurrencies, play games, use
social media and so much more.
How does Ethereum work?
Like Bitcoin, the Ethereum network exists on thousands of computers
worldwide, thanks to users participating as “nodes,” rather than a centralized
server. This makes the network decentralized and highly immune to attacks, and
essentially unable to go down as a result. If one computer goes down, it doesn’t
matter because thousands of others are holding the network up.
Ethereum is essentially a single decentralized system that runs a computer called
the Ethereum Virtual Machine (EVM). Each node holds a copy of that
computer, meaning that any interactions must be verified so everyone can update
their copy.
Network interactions are otherwise considered “transactions” and are stored within
blocks on the Ethereum blockchain. Miners validate these blocks before
committing them to the network and acting as transaction history or a digital
ledger. Mining to verify transactions is known as a proof-of-work (PoW)
consensus method. Each block has a unique 64-digit code identifying it. Miners
commit their computer power to find that code, proving that it’s unique. Their
computer power is “proof” of that work, and miners are rewarded in ETH for their
efforts.
Also, like Bitcoin, all Ethereum transactions are entirely public. Miners
broadcast completed blocks to the rest of the network, confirming the change and
adding the blocks to everyone’s copy of the ledger. Confirmed blocks cannot be
tampered with, serving as a perfect history of all network transactions.
Each transaction comes with a fee, called “gas,” which is paid by the user initiating
the said transaction. That fee is paid to the miner who validates the transaction,
incentivizing future mining and ensuring network security. Gas essentially serves
as a limit, restricting the number of actions a user can make per transaction. It’s
also in place to prevent network spam.
Because ETH is more of a utility token than a token of value, its supply is infinite.
Ether consistently enters circulation in the form of miner rewards, and it will with
staking rewards as well once the network moves to proof-of-stake (PoS). In theory,
Ether will always be in demand, meaning inflation should never devalue the asset
beyond use.
Ethereum gas fees can run quite high based on network activity. This is because
a block can only hold so much gas which varies based on transaction types and
amounts. As a result, miners will choose transactions with the highest gas fees,
meaning users are competing to validate transactions first. This competition pushes
fees higher and higher, congesting the network during busy times.
Network congestion is a significant problem, though it’s being addressed in
Ethereum 2.0 — a complete overhaul that will be discussed as a separate section.
Interacting with Ethereum requires cryptocurrency, which is stored in a wallet.
That wallet connects to DApps, acting as a passport for the Ethereum ecosystem.
From there, anyone can purchase items, play games, lend money and do all sorts of
activities just as they do on the traditional internet. Only, the traditional web is free
to users, as they’re giving away personal information. Centralized entities running
websites then sell that data to make money.
Cryptocurrency takes the place of data here, meaning users are free to browse and
interact anonymously. This also means DApp use is nondiscriminatory. For
example, no lending or banking DApp can reject someone based on their race or
financial status. An intermediary can’t block what they consider a “suspicious
transaction.” Users control what they do and how they do it, which is why many
consider Ethereum to be Web 3.0 — the future of web interaction.
Ethereum Mining
The process of creating a block of transactions to be added to the Ethereum
blockchain is referred to as mining. Ethereum currently uses a proof-of-work
blockchain but is moving to proof-of-stake (PoS) with Ethereum 2.0 for scalability
purposes and a more environmentally friendly approach.
Ethereum miners are computers that run the software and use their time and
processing power to process transactions and create blocks. Network participants
must ensure that everyone agrees on sequencing transactions in decentralized
systems like Ethereum. Miners assist in this by generating blocks by solving
computationally challenging riddles, thereby safeguarding the network from
attackers.

Bitcoin Vs Ethereum

Basis Bitcoin Ethereum

Ethereum is a decentralized global


Bitcoin is a decentralized
software platform powered by
digital currency that can be
Definition blockchain technology. It is most
transferred on the peer-to-peer
commonly known for its native
bitcoin network.
cryptocurrency, ether (ETH).

The word bitcoin was defined Ethereum was conceived in 2013 by


History in a white paper published on programmer Vitalik Buterin, and
31 October 2008. The currency then went live on 30 July 2015.
Basis Bitcoin Ethereum

began use in 2009.

The purpose of bitcoin was to The purpose of Ethereum was to


replace national currencies utilize blockchain technology for
Purpose
during the financial crisis of maintaining a decentralized payment
2008. network and storing computer code.

Although bitcoin do have smart


contracts, they are not as Ethereum allows us to create smart
flexible or complete as contracts. Smart contracts are
Smart Ethereum smart contracts. computer codes that is stored on a
Contracts Smart contracts in Bitcoin does blockchain and executed when the
not have all the functionality predetermined terms and conditions
that a programming language are met.
would give them.

Smart Contract Smart contracts on Bitcoin are Smart contracts on Ethereum are
Programming written in programming written in programming languages
Language languages like Script, Clarity. like Solidity, Vyper, etc.

Generally, bitcoin transactions Ethereum transactions may contain


Transactions
are only for keeping notes. some executable code.

Bitcoin runs on the SHA- Ethereum runs on the Keccak-


Hash Algorithm
256 hash algorithm. 256 hash algorithm.
Basis Bitcoin Ethereum

The Proof-of-Work (PoW) is


Consensus The Proof-of-Stake is the consensus
the consensus mechanism used
Mechanism mechanism used by Ethereum.
by the Bitcoin network.

The block time of bitcoin is 10 The block time of Ethereum is 14 to


Block Time
minutes. 15 seconds.

The bitcoin blockchain has a The Ethereum blockchain does not


Block Limit
block limit of 1 MB. have a block limit.

Bitcoin is the most popular Ether, native currency of Ethereum is


Popularity digital currency in the market the second-largest cryptocurrency
to date. after bitcoin to date.

Energy Energy consumption is very Energy consumption is very low as


Consumption high. compared to bitcoin

Energy Energy consumption rate of Energy consumption rate of bitcoin


Consumption bitcoin mining system 3.2 mining system 1.2 Million
rate Million household. household.

Structure of bitcoin is simple Structure of Ethereum is complex


Structure
and robust. and feature rich

Rewards Miner got nearly 6.25 BTC on Miner got nearly 5 BTC along with
Basis Bitcoin Ethereum

successfully adding new block same additional rewards on


in network. successfully adding new block in
network.

Assets Assets of Bitcoin is BTC. Assets of Ethereum is Ether.

Advantages of Ethereum
1. Decentralization
2. Anonymity
3. Lack of censorship. For example, if someone tweets something offensive,
Twitter can choose to take it down and punish that user. However, on an
Ethereum-based social media platform, that can only happen if the
community votes to do it. That way, users with different viewpoints can
discuss as they see fit, and the people can decide what should and shouldn’t
be said.
4. Community requirements also prevent bad actors from taking over.
Someone with ill intentions would need to control 51% of the network to
make a change, which is nearly impossible in most cases. It’s much safer
than a simple server that can be broken into.
5. There are smart contracts, which automate many of the steps taken by
central authorities on the traditional web. A freelancer on, for example,
Upwork must use the platform to find clients and set up payment contracts.
Upwork’s business model takes a percentage of each contract to pay its
employees, server costs, etc. On Web 3.0, a client can simply write a smart
contract that states, “If the work is turned in at X time, the funds will be
released.” The rules are hard-coded into the contract and cannot be tampered
with by either party once written.

Disadvantages of Ethereum
1. Scalability. Due to the PoW consensus algorithm, interaction is limited by
block validation times and gas fees. Furthermore, decentralization is a
hindrance. A central entity, like Visa, manages everything and has
perfected the transaction process.

2. Accessibility. As of the time of writing, Ethereum is expensive to develop


on and challenging to interact with for users unfamiliar with its technology.
Some platforms require specific wallets, which means that one must move
ETH from their current wallet to the required wallet. That’s an unnecessary
step for users ingrained in our current financial ecosystem and not beginner-
friendly in the slightest.

Programming Languages for Smart Contracts


1. Just use Solidity. To write smart contracts there are a few different
languages:
 Solidity, which is like JavaScript and has .sol as a file extension.
Solidity is the most popular right now and more robust
 Serpent, Python-like with extension .se,
 LLL, based on Lisp.
2. solc Compiler: After writing a contract in Solidity, use solc to compile it.
It’s from the C++ libraries (different implementations complementing each
other again) which can be installed here. [If you don’t want to install solc
you can also just use a browser-based compiler like the Solidity real-time
compiler or Cosmo, but the programming part later on will assume you have
solc installed.]

3. web3.js API: Once a Solidity contract is compiled with solc and sent to the
network, you can call it using the Ethereum web3.js JavaScript API and
build web apps that interact with contracts. (No need to install this yet, read
up on DApp Frameworks below first.)

Solidity
 Solidity is a brand-new programming language created by Ethereum which
is the second-largest market of cryptocurrency by capitalization, released in
the year 2015 and led by Christian Reitwiessner. Some key features of
solidity are listed below:
 Solidity is a high-level programming language designed for implementing
smart contracts.
 It is a statically typed object-oriented(contract-oriented) language.
 Solidity is highly influenced by Python, c++, and JavaScript which run on
the Ethereum Virtual Machine(EVM).
 Solidity supports complex user-defined programming, libraries, and
inheritance.
 Solidity is the primary language for blockchains running platforms.
 Solidity can be used to create contracts like voting, blind auctions,
crowdfunding, multi-signature wallets, etc.

What is Solidity Programming?


Solidity is an object-oriented programming language created
specifically by the Ethereum Network team for constructing and designing smart
contracts on Blockchain platforms.
 It's used to create smart contracts that implement business logic and generate
a chain of transaction records in the blockchain system.
 It acts as a tool for creating machine-level code and compiling it on the
Ethereum Virtual Machine (EVM).
 It has a lot of similarities with C and C++ and is pretty simple to learn and
understand. For example, a “main” in C is equivalent to a “contract” in
Solidity.
Like other programming languages, Solidity programming also has variables,
functions, classes, arithmetic operations, string manipulation, and many other
concepts.

Evolution of Solidity Programming


Solidity is a relatively new language that is rapidly growing.
 Solidity is currently the core language on Ethereum and other private
blockchains operating on competing platforms, such as Monax and
its Hyperledger Burrow blockchain which uses Tendermint for consensus.
 SWIFT has created a proof of concept that runs on Burrow and uses
Solidity.
What are EVM and Smart Contracts?
EVM or Ethereum Virtual Machine
 The Ethereum Virtual Machine (EVM) provides a runtime environment for
Ethereum smart contracts.
 It is primarily concerned with ensuring the security and execution of
untrusted programs through the use of an international network of public
nodes.
 EVM is specialized in preventing Denial-of-Service attacks and certifies that
the programs do not have access to each other's state, as well as establishing
communication, with no possible interference.

Smart Contracts
 Smart contracts refer to high-level program codes compiled into EVM
before being posted to the Ethereum blockchain for execution.
 It enables you to conduct trustworthy transactions without the involvement
of a third party; these transactions are traceable and irreversible.
 Programming languages commonly used to create and write smart contracts
are Serpent, Solidity, Mutan, and LLL.

Data Types of Solidity Programming


It supports all the common data types seen in other OOP languages, such as,
 Boolean - The Boolean data type returns ‘1' when the condition is true and
‘0' when it is false, depending on the status of the condition.
 Integer - You can sign or unsign integer values in Solidity. It also supports
runtime exceptions and the ‘uint8' and ‘uint256' keywords.
 String - Single or double quotes can denote a string.
 Modifier - Before executing the code for a smart contract, a modifier often
verifies that any condition is rational.
 Array - The syntax of Solidity programming is like that of other OOP
languages, and it supports both single and multidimensional arrays.
Apart from that, Solidity programming allows you to "Map" data structures with
enums, operators, and hash values to return values stored in specific storage places.

How to Get Started With Solidity Programming?


Version Pragma

 Pragmas are directives to the compiler about how to handle the code. Every
line of solidity source code should begin with a "version pragma," which
specifies which version of the solidity compiler to use.
 This prevents the code from being incompatible with future compiler
versions that may introduce changes.
The Contract Keyword

 The contract keyword declares a contract that encapsulates the code.


State/Declare Variables
 State variables are written on the Ethereum Blockchain and are permanently
maintained in contract storage.
 The line uint public var1 declares a state variable of type uint named var1
(unsigned integer of 256 bits), it is very similar to adding a slot in a
database.
Function Declaration

 This is a function named “set” of access modifier type public which takes a
variable a and variable b of data type uint as a parameter.
 This was an example of a simple smart contract that updates the value of
var1 and var2. Anyone with access to the Ethereum blockchain can use the
set function to change the value of var1 and var2.
 By adding the values of the variables var1 and var2, it can calculate the
variable sum.
 It will retrieve and print the value of the state variable sum using the “get”
function.
How to Execute the Code
You can execute a Solidity Program in two ways -
1. Offline Mode
2. Online Mode
Offline Mode
To operate a Solidity smart contract in Offline mode, it must meet three conditions
and follow four essential actions:
 Conditions
1. Download and install node.js.
2. Install Truffle globally.
3. Install ganache-cli.

 Actions
1. Create a truffle project and set up a development network for it.
2. Develop and deploy a smart contract for it.
3. From the Truffle console, interact with the smart contract.
4. Create tests to evaluate Solidity's primary features.
Online Mode
In the Online Mode, the Remix IDE is typically used to compile and run Solidity
smart contracts.

Advantages of Solidity Programming :


Apart from the primary functionality of Solidity Programming, there are many
other features provided by Solidity programming that cause it to have an edge over
other Ethereum based languages.
 Apart from fundamental data types, Solidity programming also allows
complex data types and member variables.
 It provides an Application Binary Interface (ABI) to enable type safety. If
the compiler discovers a data type mismatch for any variable, the ABI
generates an error.
 It refers to the ‘Natural Language Specification,' which is used to turn user-
centric specifications into language that machines can understand.
Cryptocurrencies and the real world :
Smart property :
Smart property refers to physical assets that are connected to
the digital world through the use of technology, most notably blockchain and the
Internet of Things (IoT). By digitizing ownership and enabling the transfer of
ownership through digital means, smart property offers a new way to manage,
track, and trade physical assets. This concept has gained prominence due to
advancements in blockchain technology and the desire to create more efficient,
transparent, and secure systems for asset management.
Here's a closer look at the key aspects of smart property:
1. Digital Representation: Smart property involves creating a digital
representation of a physical asset on a blockchain. This representation is
often in the form of tokens, which are cryptographic units that represent
ownership rights. These tokens are linked to the physical asset and can be
traded or transferred electronically.
2. Blockchain and Smart Contracts: Blockchain technology, which is the
foundation of cryptocurrencies like Bitcoin and Ethereum, is used to create a
decentralized and tamper-resistant record of ownership. Smart contracts,
which are self-executing code scripts, enable the automation of various
aspects of ownership and transactions. They can enforce conditions for
ownership transfer, automate payments, and ensure compliance with
predefined rules.
3. Benefits:
 Efficiency: Smart property can streamline the process of transferring
ownership, reducing the need for intermediaries and paperwork.
 Fractional Ownership: Tokenization allows for the division of
ownership into smaller units, enabling fractional ownership and
investment.
 Transparency: The blockchain's transparent and auditable nature
ensures that ownership records and transaction history are easily
accessible and tamper-proof.
 Security: Cryptographic security measures enhance the protection of
ownership rights and transaction data.
 Automated Compliance: Smart contracts can automatically enforce
legal and regulatory requirements, reducing the risk of errors and
disputes.
4. Examples of Smart Property:
 Real Estate: Real estate properties can be tokenized, allowing
investors to buy fractional ownership shares and enabling easier and
faster property transactions.
 Art and Collectibles: Artworks and collectibles can be tokenized,
facilitating ownership transfer and provenance tracking.
 Supply Chain: Smart property concepts can be applied to track the
movement and authenticity of physical goods along supply chains,
reducing counterfeiting risks.
 Vehicles: Ownership of vehicles, such as cars or airplanes, can be
represented by digital tokens, enabling easy transfer of ownership and
automated toll payments.
5. Challenges and Considerations:
 Regulation: Legal frameworks may need to adapt to accommodate
the complexities of smart property, especially when it comes to
property rights and regulatory compliance.
 Security and Privacy: Ensuring the security of digital ownership
records and protecting sensitive data are critical considerations.
 Interoperability: For widespread adoption, standards for tokenization
and smart contract protocols need to be established.
 Education and Adoption: Educating users and stakeholders about
the benefits and risks of smart property is crucial for successful
implementation.
Smart property represents a convergence of technological innovation and
traditional asset ownership, offering the potential to reshape industries and how
assets are managed, transferred, and invested in the digital age.

Applications of Cryptocurrencies and blockchain :


Cryptocurrencies and blockchains have a wide range of
applications that extend beyond simple financial transactions. Their underlying
technology offers features like decentralization, transparency, security, and
programmability, which make them suitable for various industries and use cases.
Here are some notable applications of cryptocurrencies and blockchains:
1. Financial Transactions:
 Digital Payments: Cryptocurrencies like Bitcoin and Ethereum
enable peer-to-peer transactions without the need for intermediaries
like banks.
 Remittances: Cryptocurrencies can facilitate low-cost and fast cross-
border remittances, especially for individuals sending money to
family in different countries.
 Microtransactions: Cryptocurrencies allow for very small-value
transactions, making them suitable for services like online content,
tipping, and in-game purchases.
2. Decentralized Finance (DeFi):
 Decentralized Exchanges: DeFi platforms offer decentralized trading
and exchange of assets without relying on traditional financial
intermediaries.
 Lending and Borrowing: Smart contracts enable users to lend their
assets for interest or borrow assets against collateral, all executed in a
decentralized manner.
 Stablecoins: Cryptocurrencies pegged to stable assets (fiat currencies,
commodities) provide price stability and are used in various DeFi
applications.
3. Supply Chain Management:
 Traceability: Blockchains can track the origin and movement of
products in supply chains, ensuring transparency and preventing
fraud.
 Counterfeit Prevention: By creating unique digital tokens for
physical goods, blockchains can help verify the authenticity of
products.
4. Healthcare:
 Medical Records: Blockchains can securely store and manage patient
medical records, ensuring data privacy and sharing when necessary.
 Clinical Trials: Blockchain can enhance transparency and data
integrity in clinical trial data.
5. Identity Management:
 Self-Sovereign Identity: Blockchains enable individuals to control
their personal identity data and share it selectively without relying on
central authorities.
6. Voting Systems:
 Secure Voting: Blockchain-based voting systems can enhance
transparency, security, and immutability in elections and other voting
processes.
7. Real Estate:
 Property Ownership: Blockchains can digitize and tokenize real
estate assets, making ownership and transfer more efficient and
transparent.
8. Digital Content and Intellectual Property:
 Digital Rights Management: Blockchain can track ownership and
usage rights of digital content, protecting creators' intellectual
property.
9. Energy and Utilities:
 Peer-to-Peer Energy Trading: Blockchain can facilitate direct
energy trading between producers and consumers in a decentralized
energy grid.
10. Logistics and Shipping:
 Efficiency: Blockchain can optimize and automate logistics
processes, reducing paperwork and enhancing transparency.
11. Charity and Donations:
 Transparency: Donors can track how their contributions are used and
ensure they reach the intended recipients.
12. Gaming:
 Ownership: Blockchain enables true ownership of in-game items and
characters, allowing players to trade and sell them.
These are just a few examples of how cryptocurrencies and blockchains are being
applied across different industries. The technology continues to evolve, and new
use cases are being explored to leverage the benefits of decentralization, security,
and transparency that cryptocurrencies and blockchains offer.

You might also like