Web 3 Technologies Question's
Web 3 Technologies Question's
Blockchain
Q.1 What is Electronic cash? What are the fundamental e-cash issues?
Electronic cash, also known as e-cash or digital cash, refers to a form of electronic
payment that allows users to make financial transactions without the need for physical
currency or credit cards. E-cash is typically stored in a digital wallet and can be used
to make purchases online or in person through the use of a mobile device or another
electronic payment method.
There are several fundamental issues that must be addressed in order to effectively
implement e-cash systems:
1. Security: E-cash systems must be secure to protect against fraud and ensure the
confidentiality of transactions.
2. Privacy: E-cash systems must respect the privacy of users by protecting their
personal and financial information.
3. Scalability: E-cash systems must be able to handle large numbers of
transactions efficiently and without delay.
4. Interoperability: E-cash systems must be able to work with a variety of
different payment systems and devices.
5. Regulation: E-cash systems must comply with relevant laws and regulations
related to financial transactions.
6. User acceptance: E-cash systems must be easy to use and understand in order
to gain widespread adoption.
OR
Blockchain is a shared, immutable ledger that facilitates the process of recording
transactions and tracking assets in a business network. An asset can be tangible (a
house, car, cash, land) or intangible (intellectual property, patents, copyrights,
branding). Virtually anything of value can be tracked and traded on a blockchain
network, reducing risk and cutting costs for all involved.
2. BlockP2P:
Block is made up of transactions and block header information. Blocks are data
structures that serve as containers for groups of transactions and are replicated
across all network nodes. Miners build blocks in the blockchain. Making a
legitimate block that the rest of the network will accept is called mining. The
pending transactions are collected by nodes, who then confirm their
cryptographical correctness before putting them together into blocks to be
stored on the blockchain. The Block header is the metadata that aids in
confirming a block's validity. Transactions are found in a block's remaining
space. Depending on the miner's preference, a block may include any number
of transactions.
3. NetworkConsensus:
This is a Peer-to-peer (P2P) network based on the IP protocol. It is a flat
topology with no centralized nodes. While working together using a consensus
process, all nodes equally provide and can consume services. Peers contribute
to the storage and computational resources needed for network maintenance.
P2P networks are typically more secure than centralized networks because they
lack a single point of vulnerability.The participants in a private blockchain
must be pre-verified, and they are often parties who are familiar with one
another. Every network node in a typical blockchain design keeps a local copy
of the blockchain. The P2P network on which blockchain design is based is
solely responsible for its decentralization.
4. Algorithm:
A consensus method is responsible for synchronizing all of these copies of a
single ledger. The consensus process makes sure that the local copies that each
party has been the most current and consistent with one another. Each node has
a copy that is identical or comparable to one other. One could argue that the
consensus algorithm serves as the fundamental building element of every
blockchain architecture.
Below are a few of the types of Consensus Algorithms. Proof-of-work
(POW)Proof-of-Stake (POS)Simplified Byzantine Fault Tolerance (SBFT)
Transaction
A transaction is the fundamental unit of a blockchain. A transaction represents a
transfer of value from one address to another.
Block
A block is composed of multiple transactions and some other elements such as the
previous block hash (hash pointer), timestamp, and nonce.
Peer-to-peer network
As the name implies, this is a network topology whereby all peers can communicate
with each other and send and receive messages.
Virtual machine
This is an extension of a transaction script. A virtual machine allows Turing complete
code to be run on a blockchain (as smart contracts) whereas a transaction script can be
limited in its operation. Virtual machines are not available on all blockchains;
however, various blockchains use virtual machines to run programs, for example
Ethereum Virtual Machine (EVM) and Chain Virtual Machine (CVM).
State machine
A blockchain can be viewed as a state transition mechanism whereby a state is
modified from its initial form to the next and eventually to a final form as a result of a
transaction execution and validation process by nodes.
Nodes
A node in a blockchain network performs various functions depending on the role it
takes. A node can propose and validate transactions and perform mining to facilitate
consensus and secure the blockchain. This is done by following a consensus protocol.
(Most commonly this is PoW.) Nodes can also perform other functions such as simple
payment verification (lightweight nodes), validators, and many other functions
depending on the type of the blockchain used and the role assigned to the node.
Smart contracts
These programs run on top of the blockchain and encapsulate the business logic to be
executed when certain conditions are met. The smart contract feature is not available
in all blockchains but is now becoming a very desirable feature due to the flexibility
and power it provides to the blockchain applications.
Traditional data do not exhibit immutability. The conventional database uses CRUD
(create, read, update and delete) at the primary level to ensure proper application
operation, and the CRUD model enables easy erasing and replacing of data. Such data
can be prone to manipulation by rogue administrators or third-party hacks.
On the other hand, a traditional database is centralized and does not support
transparency. Users cannot verify information whenever they want, and the
administration makes a selected set of data public. Still, however, individuals cannot
verify the data.
Censorship. Blockchain technology is free from censorship since it does not have
control of any single party. Therefore, no single authority (including governments) can
interrupt the operation of the network.
Features:
Distributed consensus
Distributed consensus is the major underpinning of a blockchain. This enables a
blockchain to present a single version of truth that is agreed upon by all parties
without the requirement of a central authority.
Transaction verification
Any transactions posted from nodes on the blockchain are verified based on a
predetermined set of rules and only valid transactions are selected for inclusion in a
block.
Generating cryptocurrency
This is an optional feature depending on the type of blockchain used. A blockchain
can generate cryptocurrency as an incentive to its miners who validate the transactions
and spend resources in order to secure the blockchain.
Limitations:
A:
Public Blockchain
Private Blockchain
Hybrid Blockchain
● Organizations who expect the best of both worlds use a hybrid blockchain,
which combines the features of both private and public blockchains.
● It enables enterprises to construct a private, permission-based system
alongside a public, permissionless system, allowing them to choose who has
access to certain Blockchain data and what data is made public.
● In a hybrid blockchain, transactions and records are typically not made
public, but they can be validated if necessary by granting access via a smart
contract.
Consortium Blockchain
● In the same way that a hybrid blockchain has both private and public
blockchain features, a Consortium blockchain, also known as a federated
blockchain, does.
● However, it differs because it involves various organizational members
working together on a decentralized network.
● Predetermined nodes control the consensus methods in a consortium
blockchain.
● It has a validator node responsible for initiating, receiving, and validating
transactions. Transactions can be initiated or received by member nodes.
This type is well used in the Bitcoin and Ethereum blockchain in the
form of a PoW mechanism.
Proof of Storage:
- This scheme allows for the outsourcing of storage capacity.
- This scheme is based on the concept that a particular piece of data is probably
stored by a node, which serves as a means to participate in the consensus
mechanism.
- Several variations of this scheme have been proposed, such as Proof of
Replication, Proof of Data Possession, Proof of Space, and Proof of
Space-time.
Proof of Authority (PoA):
- This scheme utilizes the identity of the participants called validators as a stake
on the network.
- Validators are known and have the authority to propose new blocks.
- Validators propose the new blocks and validate them as per blockchain rules.
- Commonly used PoA algorithms are Clique and Aura.
Q.10 Explain CAP theorem.
A:
1. CAP Theorem stands for Consistency, Availability, and Partition Tolerance.
According to the theory, a distributed system cannot always ensure consistency,
availability, and partition tolerance. When things go wrong, we must prioritize
at most two distributed system features and trade-offs between them.
2. CAP Theorem or Brewer’s theorem states that it is feasible to provide either
consistency or availability—but not both—in the event of a network failure on
a distributed database, a theory from theoretical computer science about
distributed data stores. In other words, according to the CAP theorem, a
distributed database system that experiences a partition must choose between
Consistency and Availability.
3. We must simultaneously communicate over the network and store data among
several nodes in a distributed system. A distributed system frequently falls
victim to network failures because of its reliance on network calls in a
significant way. Tolerance for partitions is crucial. In this situation, we must
decide, based on our needs, whether to prioritize consistency or availability.
4. With blockchain technology, immediate consistency is frequently sacrificed for
availability and partition tolerance. By requiring a specific amount of
“confirmations,” blockchain consensus techniques are simply simplified to
eventual consistency.
5. Network failures can affect any distributed system, hence network partitioning
is usually required. There are just two choices remaining in the event of a
partition: consistency or availability. The system will return an error or time out
if a specific piece of information cannot be guaranteed to be current owing to
network segmentation when consistency is chosen above availability.
6. The system will always process the query and attempt to return the most recent
version of the data even if it cannot ensure that it is up to date because of
network partitioning when availability is preferred over consistency.
7. Blockchain is a decentralized database that manages a shared ledger that cannot
be altered. Transactions are what make up the shared ledger. Consensus
techniques are used to record transactions inside the shared ledger. Sharing
distributed transactions naturally raises questions about the CAP theorem.
8. Consistency is sacrificed in Blockchain due to the priority given to Availability
and Partition Tolerance. In this case, Partition tolerance (P), Availability (A),
and Consistency (C) on the blockchain are not attained simultaneously; instead,
they are acquired over time.
Bitcoin
Q.1 How can money be sent using the Bitcoin network from one user to another?
In order to send bitcoin to another person or another wallet, you need the public
bitcoin wallet address of the receiver.
You don’t need the private keys, passphrase or seed phrase for the other wallet, and
those should be kept private by the owner at all times. The public bitcoin address is a
string of 34 letters and numbers, but most bitcoin wallets also represent it as a QR
code.
So, the person (or machine) receiving the bitcoin can also show a QR code that the
sender can scan with their own mobile wallet app.
While every wallet app will be a little bit different, this is basically how the process
goes:
1. Open your bitcoin wallet, click on “Send” and choose the currency if there’s
more than one option.
2. Paste the receiving bitcoin wallet address in the “To” field, or scan their QR
code.
3. Enter the amount you’re sending.
4. If applicable, choose your Transaction Fee setting. Regular fees cost less but
take longer whereas Priority fees cost more but finish faster.
5. After verifying that everything is correct, choose “Send Bitcoin.”
6. After you send the funds, the transaction goes to the blockchain network where
it’s verified and confirmed by Bitcoin miners
Symmetric Cryptography:
In symmetric cryptography, both sender and receiver use the same secret key to
encrypt and decrypt a message.Some of the algorithms includes Blowfish, AES, RC4,
DES, RC5, and RC6. The most widely used symmetric algorithm is AES-128,
AES-192, and AES-256. All AES algorithms use the block size of 128-bit but
different size of key lengths (128, 192, 256).
Asymmetric Cryptography?:
Asymmetric cryptography uses key pairs — public and private key. It works in a way,
message encrypted with either public or private key can only be decrypted using the
other key of the pair.
That is a public key to encrypt, private key to decrypt and private key to encrypt,
public key to decrypt. Public keys are disseminated in public networks whereas
private keys are only known to the owners.
This key pair cryptography differs from symmetric cryptography which uses one
secret key. Some of the algorithms includes RSA, ELC, Diffie-Helman key exchange,
etc. Asymmetric Cryptography has 2 usages, data encryption and digital signature.
😣
A:
Q.7 Write a short note on Mining./the mining algorithm.
3. Rewards are usually divided between the individuals who contributed, according to
the proportion of each individual's processing power or work relative to the whole
group. In some cases, individual miners must show proof of work in order to receive
their rewards.
4. Anyone who wants to make a profit through cryptocurrency mining has the choice
to either go solo with their own dedicated devices or to join a mining pool where
multiple miners and their devices combine to enhance their hashing output. For
example, attaching six mining devices that each offer 335 megahashes per second
(MH/s) can generate a cumulative 2 gigahashes of mining power, thereby leading to
faster processing of the hash function.
5. Not all cryptocurrency mining pools function in the same way. There are, however,
a number of common protocols that govern many of the most popular mining pools.
6. Proportional mining pools are among the most common. In this type of pool, miners
contributing to the pool's processing power receive shares up until the point at which
the pool succeeds in finding a block. After that, miners receive rewards proportional
to the number of shares they hold.
7. Pay-per-share pools operate somewhat similarly in that each miner receives shares
for their contribution. However, these pools provide instant payouts regardless of
when the block is found. A miner contributing to this type of pool can exchange
shares for a proportional payout at any time.
8. Peer-to-peer mining pools, meanwhile, aim to prevent the pool structure from
becoming centralized. As such, they integrate a separate blockchain related to the pool
itself and designed to prevent the operators of the pool from cheating as well as the
pool itself from failing due to a single central issue.
Smart Contracts
A smart contract is a self-executing contract with the terms of the agreement between
buyer and seller being directly written into lines of code. The code and the agreements
contained therein exist across a distributed, decentralized blockchain network. The
code controls the execution, and transactions are trackable and irreversible.
Smart contracts permit trusted transactions and agreements to be carried out among
disparate, anonymous parties without the need for a central authority, legal system, or
external enforcement mechanism.
● Speed, efficiency and accuracy
Once a condition is met, the contract is executed immediately. Because smart
contracts are digital and automated, there’s no paperwork to process and no
time spent reconciling errors that often result from manually filling in
documents.
● Trust and transparency
Because there’s no third party involved, and because encrypted records of
transactions are shared across participants, there’s no need to question whether
information has been altered for personal benefit.
● Security
Blockchain transaction records are encrypted, which makes them very hard to
hack. Moreover, because each record is connected to the previous and
subsequent records on a distributed ledger, hackers would have to alter the
entire chain to change a single record.
● Savings
Smart contracts remove the need for intermediaries to handle transactions and,
by extension, their associated time delays and fees.
Note the following answer is written by an AI , However I can vouch that it's
correct.
Network-assisted proofs, on the other hand, are a type of cryptographic technique that
enables a prover to prove to a verifier that a statement is true by relying on the
consensus of a network of nodes. In the context of smart contracts, network-assisted
proofs can be used to enable decentralized verifications of statements, such as the
verification of the authenticity of a document or the existence of a particular asset.
Overall, both software-assisted proofs and network-assisted proofs are useful tools for
enabling verifiable computations and statements in smart contracts, and can be used to
increase the security and trustworthiness of these systems.
Ethereum
1
Y(S, T)= S'
2
Given an old valid state (S) and a new set of valid transactions (T), the Ethereum state
transition function Y(S, T) produces a new valid output state S'
State
In the context of Ethereum, the state is an enormous data structure called a modified Merkle
Patricia Trie, which keeps all accounts linked by hashes and reducible to a single root hash
stored on the blockchain.
Transactions
Transactions are cryptographically signed instructions from accounts. There are two types of
transactions: those which result in message calls and those which result in contract creation.
Contract creation results in the creation of a new contract account containing compiled smart
contract bytecode. Whenever another account makes a message call to that contract, it
executes its bytecode.
2. Private mainnet:
In a private Ethereum network, membership is controlled and limited to certain
users who are carefully selected by administrators. It is used to protect against
malicious attacks and limit access only to trusted parties — which makes it an
ideal solution for companies looking to develop applications based on
cryptocurrency.
Private networks can be built in-house or hosted by a third-party service
provider such as Microsoft Azure or Amazon Web Services.
3. Testnet:
The testnet is used by those who want to experiment with their code before
launching it on the mainnet. Users who want to try out the testnet can create a
new node and join the network — or they can connect their private networks to
the public testnet.
A functional public testnet is a necessary component of an Ethereum-based app
as most developers use it to test their apps, smart contracts, and other solutions
based on blockchain technology.
Sharding drastically reduces the amount of work that a full node must do to
maintain the state of a decentralized application (dapp).
Rather than using a large number of full nodes to ensure security, only the
nodes that need to be updated are updated.
There is also no need for the network leader (or “faucet”) node anymore.
Alternative Answer
Public Ethereum
Public networks are accessible to anyone in the world with an internet connection.
Anyone can read or create transactions on a public blockchain and validate the
transactions being executed. The consensus among peers decides on the inclusion of
transactions and the state of the network.
You should test any contract code you write on a testnet before deploying to
Mainnet. Among dapps that integrate with existing smart contracts, most
projects have copies deployed to testnets.
You can also choose between which testnet you would like to play around with
like Sepolia , Goreli , etc.
- Layer 2 Testnets: Layer 2 (L2) is a collective term to describe a specific set of
Ethereum scaling solutions. A layer 2 is a separate blockchain that extends
Ethereum and inherits the security guarantees of Ethereum. Layer 2 testnets are
usually tightly coupled to public Ethereum testnets.
Private Ethereum
An Ethereum network is a private network if its nodes are not connected to a public
network (i.e. Mainnet or a testnet). In this context, private only means reserved or
isolated, rather than protected or secure.
There are two ways you can have your own private ethereum network:
- Development networks : To develop an Ethereum application, you'll want to run
it on a private network to see how it works before deploying it. Similar to how
you create a local server on your computer for web development, you can
create a local blockchain instance to test your dapp. This allows for much faster
iteration than a public testnet.
- Consortium networks: The consensus process is controlled by a predefined set
of nodes that are trusted. For example, a private network of known academic
institutions that each govern a single node, and blocks are validated by a
threshold of signatories within the network.
- Nodes: Nodes are the computers that run the Ethereum software and maintain a
copy of the Ethereum blockchain. They validate and relay transactions and
blocks, and help to keep the Ethereum network secure.
- Miners: Miners are nodes that perform the work of validating and adding new
blocks to the Ethereum blockchain. They do this by solving complex
mathematical problems, a process known as "mining." When a miner
successfully adds a new block to the blockchain, they are rewarded with a
small amount of Ether (the native cryptocurrency of Ethereum).
- 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. They are stored and replicated on the Ethereum blockchain and can be
used to facilitate, verify, and enforce the negotiation or performance of a
contract.
● Uncle hash: This is the hash of one of the "uncles" of the block, which are
blocks that were mined but not included in the main blockchain.
● Coinbase: This is the Ethereum address of the miner who mined the block.
● Root: This is the root of the state tree, which is a data structure that represents
the state of the Ethereum network at a given point in time.
● Difficulty: This is the difficulty level of the block, which determines how hard
it was to mine the block.
● Gas limit: This is the maximum amount of gas that can be consumed by the
transactions in the block.
● Gas used: This is the actual amount of gas consumed by the transactions in the
block.
● Extra data: This is a field that can be used to include additional data in the
block header.
Q.12 What are the client software and wallets that are available with Ethereum?
A wallet is a generic program that can store private keys and, based on the addresses
stored within it, it can compute the existing balance of ether associated with the
addresses by querying the blockchain.
The following is a non-exhaustive list of the client software and wallets that are
available with Ethereum:
1. Geth: This is the official Go implementation of the Ethereum client.
2. Eth: This is the C++ implementation of the Ethereum client.
3. Parity: This implementation is built using Rust and developed by Parity
4. technologies.
5. Trinity: Trinity is the implementation of the Ethereum protocol. It is written in
Python.
6. Light clients:
● Simple Payment Verification (SPV) clients download only a small
subset of the blockchain.
● This allows low resource devices, such as mobile phones, embedded
devices, or tablets, to be able to verify the transactions.
● A complete Ethereum blockchain and node are not required in this case,
and SPV clients can still validate the execution of transactions.
● SPV clients are also called light clients.
2. Swarm:
Ethereum Swarm is basically a giant DHT. DHTs are used in many storage
solutions (like BitTorrent or IPFS) as a database where peers can find where the
data is stored. Swarm uses the DHT in a different way because it stores the data
itself in the DHT. Swarm calls this solution DISC which means Distributed
Immutable Store for Chunks. When you store anything in Swarm, it splits it
into 4K chunks. These chunks are addressable by the chunk hash and stored on
nodes that are the nearest to the chunk address. Every chunk is stored
redundantly on the 4 nearest nodes.
The network structure of Swarm is stable and highly optimized for the DHT.
Because of this optimized network structure, the content retrieval in Swarm is
really efficient. Swarm calls this Kademlia connectivity.
Unit III
Web3
Q.1 How Truffle can be used to test and deploy smart contracts?
Truffle is a popular development framework for Ethereum that allows you to write,
test, and deploy smart contracts. Here is a basic outline of how to use Truffle to test
and deploy your contracts:
- Install Truffle: Make sure you have Truffle installed on your machine. You can
install it using npm by running the following command: npm install -g truffle.
- Create a Truffle project: Create a new folder for your Truffle project and
navigate to it in your terminal. Then, run the command truffle init to create a
new Truffle project in the current directory. This will create a default Truffle
project structure with the following directories:
- Compile your contract: Run the command truffle compile to compile your
contract. This will generate a JSON file for your contract in the build/contracts
directory.
- Write tests: Write test scripts for your contract in the test directory using
JavaScript and the Truffle testing library.
- Run your tests: Run the command truffle test to run your tests and ensure that
your contract is working as expected.
IPFS aims to replace HTTP as the protocol of choice for delivery of web applications.
Instead of storing a web application on a single server, the files are stored on IPFS and
can be retrieved from any IPFS node.
To deploy your application on IPFS, you will need to follow these steps:
- Install the IPFS client on your machine. This will allow you to interact with the
IPFS network and perform various actions such as adding and fetching files.
- Add your application's files to the IPFS network. You can do this using the ipfs
add command, which will add the files to your local IPFS node and return a
content hash for each file.
- Update your application to use the content hashes or ENS names to retrieve the
necessary files from the IPFS network. This can typically be done using an
IPFS library or plugin that provides a simple API for interacting with the IPFS
network.
Serenity
Serenity is a proposed upgrade to the Ethereum blockchain that aims to address the
scalability trilemma by improving the scalability and security of the Ethereum
network while maintaining decentralization. It does this through the use of various
technologies such as sharding and proof of stake. However, it is important to note that
the scalability trilemma is a fundamental challenge that all blockchain systems face,
and it remains to be seen how effectively Serenity will be able to address it.
Sharding
Sharding is a technique that aims to increase the Ethereum blockchain's total
throughput rate by dividing the validation responsibility among many nodes. This is
done by storing different parts of the state in different nodes and directing transactions
to different nodes depending on which shards they affect, allowing for parallel
processing. The goal of sharding is to allow Ethereum to scale to practical levels for
applications while maintaining decentralization and security. It is similar to sharding
techniques found in traditional databases.
https://medium.com/hackernoon/tackling-ethereums-blockchain-trilemma-via-serenity
-ethereum-2-0-1fb423a6b184
Q.5 What are the four phases in the development of Ethereum 2.0?
1. Phase 0:
● The main work included in Phase 0 is around the management of
validators and the staking mechanism.
● In addition, this phase also includes block proposer selection, consensus
mechanism rules, and a reward/penalty mechanism.
● This stage involves the creation of a core system chain called the beacon
chain, which can be considered the backbone of the entire Ethereum 2.0
chain system.
● After Phase 0 is complete, there will be two chains in existence: the
original Ethereum 1.0 chain and a new chain called the beacon
chain.These chains will operate in parallel.
● The Phase 0 specification and development can be further divided into
multiple categories, the first of which is the beacon chain
2. Phase 1:
● Phase 1 includes the development of shard chains and blocks.
● Phase 1.5 also known as "the merge" is where ethereum mainnet will
transit into Ethereum 2 most likely by becoming a shard chain of
Ethereum 2.0.
● Shard chains are the main scalability feature that will initially consist of
64 chains and will grow over time as required.
● The main design goals in this phase revolve around creation, validation,
and consensus of the data of shard chains.
● The state of each shard chain will be written periodically to the beacon
chain.
● This is called a crosslink, which is a set of signatures from a set of
validators (the committee) that has attested to a block in a shard chain.
● This crosslink is included in the beacon chain representing the
attestation of blocks of shard chains.
● The idea behind this mechanism is that when a block in the beacon
chain is finalized, the corresponding block in the shard chain is also
considered final.
3. Phase 2:
● Phase 2 will have the ability to run smart contracts and transactions on
shard chains.
● In addition, constructs such as accounts will also be available with this
phase.
● Each shard chain in Phase 2 will have its own ewasm EVM, which will
allow for faster running of smart contracts.
● There is also a concept of the execution environment, which allows
shards in Phase 2 to build custom environments for specific use cases.
● This gives tremendous flexibility to developers, as it allows them to
build fully customized execution environments.
● It is quite early to say how exactly these execution environments will be
designed because of the rapidly evolving research in this space.
4. Phase 3:
● Phase 3 is to be a continuous improvement and maintenance stage,
where a complete Ethereum 2.0 chain will be running and evolving into
a more mature and feature-rich blockchain.
Hyperledger
b. Sawtooth:
Hyperledger Sawtooth is a blockchain project proposed by Intel in April
2016. It was donated to the Linux foundation in 2016.
Sawtooth introduced some novel innovations focusing on the decoupling of
ledgers from transactions, flexible usage across multiple business areas
using transaction families, and pluggable consensus.
c. Iroha:
Iroha was contributed by Soramitsu, Hitachi, NTT Data, and Colu in
September 2016.
Iroha aims to build a library of reusable components that users can choose
to run on their own Hyperledger-based distributed ledgers.
d. Indy:
Indy is a distributed ledger developed for building decentralized identities.
It provides tools, utility libraries, and modules, which can be used to build
blockchain-based digital identities.
e. Besu:
Besu is a Java-based Ethereum client.
It is the first project under Hyperledger that can operate on a public
Ethereum network.
f. Burrow:
Hyperledger Burrow was contributed by Monax.
Burrow introduces a modular blockchain platform and an Ethereum Virtual
Machine (EVM)-based smart contract execution environment.
2. Libraries:
Currently, there are four library projects under the Hyperledger umbrella:
a. Aries:
Aries is not a blockchain; in fact, it is an infrastructure for
blockchain-rooted, peer-to-peer (P2P) interactions.
The aim of this project is to provide code for P2P interactions, secrets
management, verifiable information exchange, interoperability, and secure
messaging for decentralized systems.
The eventual goal of this project is to provide a dynamic set of capabilities to
store and exchange data related to blockchain-based identity.
b. Transact:
Transact provides a shared library that handles smart contract execution.
This library makes the development of distributed ledger software easier by
allowing the handling of scheduling, transaction dispatch, and state
management via a shared software library.
It provides an approach to implement new smart contract development
languages named smart contract engines.
Two main examples of such engines are Seth (for EVM smart contracts) and
Sabre (for web assembly Wasm-based smart contracts).
c. Quilt:
This utility implements the Interledger protocol, which facilitates
interoperability across different distributed and non-distributed ledger
networks.
d. Ursa:
Ursa is a shared cryptography library that can be used by any project,
Hyperledger or otherwise, to provide cryptography functionality.
There are two sub-libraries available in Ursa: LibUrsa and LibZmix.
LibUrsa is designed for cryptographic primitives such as digital signatures,
standard encryptions schemes, and key exchange schemes.
LibZmix supports signature Proofs of Knowledge (PoK), bullet proofs, range
proofs, and set memberships.
3. Tools:
a. Avalon:
Avalon provides a trusted computer framework that enables privacy and
allows off-chain processing of compute-intensive operations in a trusted and
secure manner.
It provides a guarantee that a computation was performed correctly and
privately.
b. Cello:
The aim behind Cello is to allow the easy deployment of blockchains.
This will provide an ability to allow as a service deployments of a
blockchain service.
c. Caliper:
It can be used to measure the performance of any blockchain.
There are different performance indicators supported in the framework.
These include success rate, transaction read rate, throughput, latency, and
hardware resource consumption, such as CPU, memory, and I/O.
Ethereum, Fabric, Sawtooth, Burrow, and Iroha are currently the supported
blockchains in Caliper.
d. Explorer:
This project aims to build a blockchain explorer for Hyperledger Fabric that
can be used to view and query the transactions, blocks, and associated data
from the blockchain.
It also provides network information and the ability to interact with chain
code.
4. Domain-specific:
a. Grid:
Grid is a Hyperledger project that provides a standard reference
implementation of supply chain-related data types, data models, and relevant
business logic encompassing smart contracts.
b. Labs:
Hyperledger labs provide a quick and easy way to start a project under
Hyperledger without going through the official formal process of incubation
and activation.
This allows the development of research projects, hackathons, and demo
projects.
d. Security and crypto: These services are responsible for providing the
capability to allow various cryptographic algorithms or modules to
provide privacy, confidentiality, and non-repudiation services.
f. Policy services: This set of services provides the ability to manage the
different policies required for the blockchain network.
d. Security and crypto: These services are responsible for providing the
capability to allow various cryptographic algorithms or modules to provide
privacy, confidentiality, and non-repudiation services.
e. Data store: This component provides an ability to use different data stores
for storing the state of the ledger.
f. Policy services: This set of services provides the ability to manage the
different policies required for the blockchain network.
g. APIs and SDKs: This component allows clients and applications to interact
with the blockchain.
For each and every transaction in the fabric, the following steps are followed-
1. Creation of the proposal:
Imagine a deal between a smartphone manufacturer company and a smartphone
dealership.
The transaction begins when a member organization proposes or invokes a
transaction request with the help of the client application or portal.
Then the client application sends the proposal to peers in each organization for
endorsement.
2. Endorsement of the transaction:
After the proposal reaches the endorser peers (peers in each organization for
endorsement of a proposal) the peer checks the fabric certificate authority of
the requesting member and other details that are needed to authenticate the
transaction.
Then it executes the chain code (a piece of code that is written in one of the
supported languages such as Go or Java) and returns a response.
This response indicates the approval or rejection of the following transaction.
The response is carried out to the client.
3. Submission to ordering service: After receiving the endorsement output, the
approved transactions are sent to the ordering service by the client-side
application. The peer responsible for the ordering service includes the
transaction into a specific block and sends it to the peer nodes of different
members of the network.
4. Updating the ledger: After receiving this block the peer nodes of such
organizations update their local ledger with this block. Hence the new
transactions are now committed.
b. Upgrade a chaincode:
You can upgrade a chaincode using the same Fabric lifecycle process as
you used to install and start the chaincode. You can upgrade the
chaincode binaries, or only update the chaincode policies.
Follow these steps to upgrade a chaincode:
1. Repackage the chaincode
2. Install the new chaincode package on your peers
3. Approve a new chaincode definition
4. Commit the definition to the channel
c. Deployment Scenarios:
1. Joining a channel:
A new organization can join a channel with a chaincode already
defined, and start using the chaincode after installing the
chaincode package and approving the chaincode definition that
has already been committed to the channel.
2. Updating an endorsement policy:
You can use the chaincode definition to update an endorsement
policy without having to repackage or re-install the chaincode.
Channel members can approve a chaincode definition with a new
endorsement policy and commit it to the channel.
OR
Tokenization
Trustless System
In the conventional payment system, sometimes transactions do not only involve two
parties but also intermediaries such as banks or payment providers. When we
implement blockchain tokenization, the distributed network nodes verify the
transactions through a process known as mining and so blockchain for a reason is
often referred to as “trustless system”. This eliminates the risk of trusting an
organization and reduces the overall cost of transactions by cutting out third parties.
Stability
Confirmed blocks of blockchain are resistant to the modification of data, which means
there are no chances of deletion and changes in data after it has been registered in the
blockchain. This makes it feasible to store the financial data in the blockchain as it
provides greater stability and security.
Disadvantages
Data Modification
One of the downsides of implementing Blockchain is data modification; once data has
been added to Blockchain, it is very difficult to modify it and this stability is
disadvantageous. But changing blockchain data or code is demanding and it becomes
difficult when needed, where one chain has to be abandoned and a new one is taken
up.
Storage
Blockchain logs can grow very large over time. The Bitcoin blockchain requires
around 200 GB of storage and the growth in the blockchain size appears to be
increasing, resulting in the network risks losing nodes if the log becomes too large for
the storage and downloads.
Private Keys
Blockchain uses asymmetric cryptography to give ownership to its users over their
cryptocurrency unit. Each Blockchain address has a respective private key. While the
Blockchain address is shareable, the private key should be kept confidential. To access
the funds, each user needs a private key. In cases, where an individual loses the private
key, the money is lost and there is no way out!
Prone to Attacks
The Proof of Work algorithm efficiently protects the Bitcoin blockchain. But there
have been fewer potential attacks that are performed against the blockchain and 51
percent among them are most discussed. This attacks can be successful when only one
entity handles more than 50 percent of network hashing power, which allows them to
disrupt the whole network.
- Security tokens: These are tokens that represent ownership of an asset, such as
stocks, bonds, or real estate. They are subject to federal securities regulations.
These are securitized cryptocurrencies that derive value from an external asset
that can be traded under a financial regulation as security.
- Non-fungible tokens (NFTs): These are unique tokens that represent ownership
of a one-of-a-kind asset, such as a piece of art or a collectible. These is unqiue
to the holder and the creator of the collectible. One can launch NFTs using
ERC721 and ERC1155 standards on Ethereum.
- Stablecoins: These are tokens that are pegged to a stable asset, such as a fiat
currency or commodity, in order to minimize price volatility. As the name
suggests, these are tokens of a stable value in nature in that their value is
somewhat predictable in the sense that it remains the same almost all the time.
Stable tokens or stablecoins as they are mainly called, are backed by a stable or
fairly value-stable asset like fiat. So we have dollar and Euro-stabilized or
backed stable coins, gold and other precious metals, oil, and
commodity-backed tokens.
- Governance tokens: These are tokens that give holders voting rights in
decision-making processes within a blockchain network or organization.
- Reward tokens: These are tokens that are given to participants in a blockchain
network as a reward for contributing resources, such as computing power or
storage, to the network.
Q.3 Explain Process of tokenization.
This is as per Mam’s PPT
• Almost any asset can be tokenized and presented on a blockchain,
such as commodities, bonds, stocks, real estate, precious metals,
loans, and even intellectual property.
• Physical goods that are traditionally illiquid in nature, such as
collectibles, intellectual property, and art, can also be tokenized and
turned into liquid tradeable assets.
• The first step is to onboard an investor who is interested in
tokenizing their asset.
• The asset that is presented for tokenization is scrutinized and
audited, and ownership is confirmed.
• The process of tokenized security starts, which leads to the security
token offering(STO).
• The physical asset is placed with a custodian (in the real world) for
safekeeping.
• The derivative token, representing the asset, is created by the
organization offering the token and issued to investors through a
blockchain.
• Traders start to buy and sell these tokens using trading exchanges in a
secondary market and these trades are settled (the buyer makes a
payment and receives the goods) on a
https://ethereum.org/en/developers/docs/standards/tokens/
Solidity Programming
Address types are Ethereum addresses that equate to 20 bytes, and are represented in
hexadecimal form beginning with the prefix 0x.
Most other types will be familiar to you as a developer - including booleans, integers,
fixed-point numbers, byte arrays, and literals.
Data Storage
In Solidity, reference data values can be stored as storage, memory or calldata
depending on the role of the data stored. In particular:
storage : keeps the data permanently on the blockchain, and is extremely expensive.
memory: values are stored only for the lifetime of the smart contract's execution, and
are inexpensive to use (costing only small amounts of gas).
calldata: is a special data location that contains the function arguments, and is only
available for external function call parameters.
Function Modifiers
Functions exist to get/set information based on calls initiated by external transactions.
In particular, a smart contract can never run unless initiated by an external transaction
- they don't execute silently in the background.
view: This guarantees that the function will not modify the state of the contract's data
(or data in storage).
pure: This guarantees that the function with neither read nor modify the state of the
contract's data.
payable: Functions and addresses declared payable can receive ether into their
contracts.
event TestEvent (
uint256 date,
string value
);
Events are stored in the receipts of transactions and can be accessed there.
You can subscribe to an event with myContract.events.TestEvent([options][,
callback])
You can request past events using a request like myContract.getPastEvents(event[,
options][, callback]).
// Creating a contract
contract Solidity_var_Test {
// Defining a constructor
constructor() public {
state_var = 16;
}
}
● To access restrictions
● Input accuracy checks
● Hacks protection
In addition to these basic types, Solidity also supports arrays, structs, and enums,
which can be used to store and manipulate more complex data structures.
- Literals: These are fixed values that can be assigned to variables. Examples
include numbers (e.g., 42), strings (e.g., "Hello, World!"), and booleans (e.g.,
true or false).
- Variables: These are named locations in memory that can hold a value.
Variables must be declared before they can be used in your code, and they can
be of various types (e.g., int, uint, bool).
- Operators: These are symbols that perform operations on one or more operands
(values or variables). Examples include arithmetic operators (e.g., +, -, *, /),
comparison operators (e.g., ==, !=, >, <), and logical operators (e.g., &&, ||, !).
- Function calls: These are expressions that invoke a function and return the
value returned by that function. Function calls can be made to both internal
(i.e., within the current contract) and external (i.e., another contract) functions.
If statement
This is the most basic conditional statement. It is used to make a decision whether the
statement or block of code will be executed or not. If the condition is true the
statements will be executed, else no statement will execute.
Syntax:
if (condition) {
statement or block of code to be executed if the condition is True
}
if…else statement
This statement is the next form of conditional statement which allows the program to
execute in a more controlled way. Here if the condition is true then the, if block is
executed while if the condition is false then the else block, is executed.
if (condition) {
statement or block of code to be executed if condition is True
} else {
statement or block of code to be executed if condition is False
}
This contract has a balance that is stored on the blockchain and two functions:
addFunds and withdraw. The addFunds function allows users to add funds to the
balance, while the withdraw function allows them to withdraw funds from the balance.
The withdraw function also includes a require statement that checks that the balance is
greater than or equal to the amount being withdrawn. If it is not, the transaction will
fail and an error message will be displayed.
You can deploy this contract to the Ethereum blockchain using a tool like Remix,
which is a browser-based Solidity compiler and runtime environment. You can then
interact with the contract using Remix or a tool like MetaMask, which is a browser
extension that allows you to send transactions and interact with contracts on the
Ethereum blockchain.
1. Single Inheritance
In Single or single level inheritance the functions and variables of one base contract
are inherited to only one derived contract.
2. Multi-level Inheritance
It is very similar to single inheritance, but the difference is that it has levels of the
relationship between the parent and the child. The child contract derived from a parent
also acts as a parent for the contract which is derived from it.
3. Hierarchical Inheritance
In Hierarchical inheritance, a parent contract has more than one child contracts. It is
mostly used when a common functionality is to be used in different places.
4. Multiple Inheritance
https://www.alchemy.com/overviews/solidity-interface
Revert
Revert does not evaluate any condition and does not depend on any state or statement.
The revert statement is similar to the require statement in that the revert function can
handle the same error types as the require function, but it is more appropriate for
complex logic gates.
If a revert statement is called, the unused gas is returned and the state reverts to its
original state. The ability to add a custom message is the same as the require function.
Assert
Assert is a function that is used to check for code that should never be false, and plays
an important role in preventing impossible scenarios. If the assert function returns a
boolean value of true, then a terminal bug will be displayed and the programs will not
execute.
In contrast to the require and revert functions, assert does not return any unused gas
and instead, the assert function will consume the gas supply before proceeding to
reverse the program to its original state. Interestingly, prior to the Byzantium fork,
both the require and assert functions behaved in an identical manner, however,
compiled to distinct opcodes.
On the other hand, an abstract contract is a contract that contains both function
declarations and implementation code, but the implementation code is incomplete. An
abstract contract is used as a base contract from which other contracts can inherit and
override the implementation code.
Logs and events are often referred to synonymously. Events allow you to ‘print’
information to the logging structure in a way that is more gas-efficient since the
information is not stored in a storage variable, which takes up more gas. Events, or
logs, live in the Transaction Receipts trie, which is inaccessible to smart contracts.
Solidity events are interfaces with EVM logging functionality. You can add an
attribute indexed to up to three parameters. Then they appear in the structure of topics,
not the data portion of the log. When parameters do not have the indexed attributes,
they are ABI-encoded into the data portion of the log.
There are two types of Solidity events: those which are indexed and those which are
not.
When parameters do not have the indexed attribute, they are ABI-encoded into the
data portion of the log. These parameters form the byte array of the event. Data is
encoded according to its type and can be decoded according to a schema.
Indexed parameters are also known as “topics”, are the searchable parameters in
events. The indexed parameters will allow you to search for these events using the
indexed parameters as filters. You can add an attribute indexed up to 4 parameters or 3
parameters based on whether the events are anonymous or not, respectively.
Q.15 Explain the use of assert and revert in solidity with the help of an example.