0% found this document useful (0 votes)
20 views20 pages

Important Question and Answers

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)
20 views20 pages

Important Question and Answers

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/ 20

Unit-3

1) Explain about cryptographic tokens and types of Block Chain


applications.
• Ans) A cryptographic token represents a programmable asset that is created and
managed by a smart contract.
• The smart contract decides the number of units of tokens to be created and handles the
transactions involving the token and each token holder’s balance.
• While a cryptocurrency such as ETH will be available for all the applications
implemented on Ethereum, the cryptographic token is implemented by a particular
application and can be accessed and controlled only by the smart contract belonging to
that particular application.
• It is important to remember the difference between a coin and a token.
• Coins are native to the platform and are accessible to all applications developed using the
platform whereas token are accessible to the application that creates token on the platform.
CRYPTOGRAPHIC TOKENS
• Utility Tokens
• Security Tokens
• ERC Tokens

Utility Tokens
• Utility tokens are user tokens that provide access to the products or services offered by the
company.
• They can help in driving the internal economy within a blockchain project.
• They can be used to provide advantages to the holders of the utility tokens.
For example, Golem Network Token (GNT) provides the holders access to the Golem ecosystem

Security Tokens
• Security tokens are tokens that represent legal ownership of a physical or digital asset.
• They are generally tied to the company’s profit and loss valuation.
• These tokens are heavily regulated, and failing to comply with the regulations shall have serious
consequences which can be even lead to the shutdown of the complete blockchain project.
Some examples of security tokens are
• Siacoin token,
• Blockstack STX token, etc.

ERC Tokens

• Token management attributes are irrespective of domains where these are used.
• The Ethereum community has taken a lead on this and EIPs standardized definition for
developers to code and deploy.
• ERC tokens define rules that will enable the tokens to be handled and exchanged between
various DApps and wallets.

Examples
• ERC20 TOKENS.
• ERC721 TOKENS.

Types of block chain applications


• Fully Decentralized Applications.
• Simple Blockchain Solutions.
• Enterprise Solutions.
• Enterprise Blockchain Ecosystems.

• Fully Decentralized Applications.

Most public blockchain solutions fall into this category.

Cryptocurrency as well as other asset trading can be done using blockchain technology and
solutions can be provided to end user using existing public blockchain networks.
Cryptocurrencies and tokens are example of these applications.

• Simple Blockchain Solutions.

Simple blockchain solutions refer to simple and independent blockchain solutions that help
realization of certain business processes.

Many times, these solutions are done as experimentation to evaluate or build confidence of
stakeholders.

• Enterprise Solutions.

Once simple solutions build confidence among stakeholders and proof-of-value is established,
enterprise systems get integrated with the blockchain solution that has been built.

This helps automate significant work as existing enterprise assets supporting business processes
get utilized to initiate transactions and respond to events coming from blockchain.

• Enterprise Blockchain Ecosystems.

• With the success of blockchain solutions, more stakeholders start joining the network to realize
their business value.
• It reaches a critical mass to create enterprise ecosystem using blockchain to deliver value to end
customers and create value for stakeholders.

2) Write the Approaches of designing Block Chain applications

Ans)

Use Case Capture

• To solve enterprise problems using blockchain, it is important to capture use case or list of
potential use cases that can be solved using blockchain.
• These use cases need collaboration or information sharing.
Documentation of use cases needs to be done to an extent that it is possible to evaluate the
relevance of use case for blockchain and articulate benefits that use the blockchain would
provide.

Block chain Relevance Evaluation


• This or a similar framework needs to be applied on the use case identified to judge if it is
worth exploring the use of blockchain in an overall solution.

Identification of Actors
• Like every other software solution, the key is to identify actors in the given problem
statement.
• In the case of blockchain, some of the actors might be enterprise systems or devices.
• These should also be explicitly captured so that subsequent design happens in good amount
of details.

Activity Diagram:
• Activity diagrams will document all the interactions actors will have with the system and with
each other.
It will be good if these activities are captured, in order to mention activities that would be
automated and those that would not be automated

Sequence Diagram
• Sequence diagrams list details of sequences for each of the transactions.
• These diagrams should be detailed in iterative fashion to capture the detailed technical
interactions and their sequences.
• These help in identification of methods class objects will need to have as well as orchestration
of these methods in the solution.

State Diagram

• State diagrams help identify workflow or workflows that need to be taken care of during
implementation of the blockchain solution.
• These will also identify state database that needs to be maintained at node, and the
conditions and events that a smart contract will need to have in an eventual solution.

Solution Architecture:
• Solution architecture lays down components and their interaction in the overall network. This
will help understand building blocks of the solutions and will have different views so as to
interact with relevant stakeholders.
Unit-4

3) Write a short note Smart Contract Programming


Ans) Ethereum supports different languages such as Solidity,

• Bamboo,

• Vyper,

• Flint, etc., to write smart contracts.

Solidity is the most popular and widely used language for Ethereum smart contract programming

• Solidity is a high-level language influenced by C++, Python, and JavaScript.


• It resembles a lot with JavaScript and supports multiple data types,
• conditional statements, and
• loops.
• The language supports object-oriented features such as
• inheritance,
• interfaces,
• class,
• functions, and properties.
• It also supports libraries and complex user-defined types.

Layout of a Solidity Source File


Example

Pram directive
• A Solidity source code should mandatorily begin with a pragma directive, followed by optional
import directives and one or more contract definitions.
• The pragma enables certain compiler features or checks.
• since it is local to a source file, it has to be added separately in each file if the solution has
multiple Solidity files.
• The most commonly used pragma directive is version pragma, which would look like pragrna
solidity 0.5.2. the compile will happen only on Solidity version 0.5.2.
• The following usage of pragma solidity A0.5.2 means compile on version starting from 0.5.2 up
to 0.6
• . Another way of specifying version pragma is pragma solidity >=0.4.0 < 0. 7 .0. This signifies
that the target compiler version for source code can start from 0.4.0 up to but not including
0.7.0.
import directive
• The next directive after pragma is an optional import directive.
• It can be defined to include symbols from the code present in another file.
• The syntax is import "filepath".
For example,
import globalcontracts.sol
• The import statement treats all file they begin with (current directory) or .. (paren1 directory).

Contract

• This is similar to defining a class in any object-oriented programming language.

• Inside this definition is all the variables and functions parts of that contract.

• Although multiple contracts can be defined in the same source file, it is recommended to limit
to one contract per file for the sake of modularity.

• A simple contract definition would look as follows.

• It declars one variable and two functions.

• Similar to constructors for a class in most other object-oriented languages Solidity allows
defining constructor inside a contract.

• A contract can also be instantiated from other contracts and the instance variable can be used
to invoke the functions of the contract to where it points

Date Types in Solidity


Expressions and Control Structures

• Solidity supports control structures supported in most of the languages –

• if,

• else,

• while,

• do,

• for,

• Break

• continue,

• return.

• The syntax would be similar to JavaScript or C language.

However, there is no auotmatic type conversion from non-Boolean to Boolean type


Contract Instance and Function Calls

• Solidity contracts can be instantiated using the keyword new.

• The above-mentioned code has two contracts named D and C.

• Inside C, the first line creates an instance of contract D and stores that instance in a variable
named D.

• It is also possible to send ether while creating the instance of D using .value() option.

• The target constructor has to be marked as payable to accept ether/gas

Functions

• Functions within a contract can be called directly as shown below. Here, function g is called
from function
• functions of other contracts to have to be called externally.

• Function funC1 belongs to contract c1.

• The second contract c2 instantiates an object of c1 and then calls funC1 through it

2) Write a short notes on , . Ganache ii. Unit testing iii. Ethereum accounts iv. Truffle
framework

i. Ganache
ii. Unit testing

• Running truffle test command and from VS Code terminal or simply test inside truffle
develop interactive console will execute the unit test cases.

• After unit testing on local blockchain network, the smart contract can be migrated to
other networks.

• when using Ganache to work locally, Ethereum accounts with some Ethers that are
needed to migrate and perform transactions were automatically generated.

iii. Ethereum accounts

• an Ethereum account is a combination of public-private key pair created using Elliptic


Curve Digital Signature Algorithm (ECDSA).

• This account is represented by a hexadecimal value known as address.

• The address is obtained by computing keccak-256 hash of the public key and taking
rightmost 20 bytes of that hash.

• An Ethereum address would look like this-


Ox9£8702f95eed51a9418fdda5c8d6ad06335c70a6

create new Ethereum accounts-

• there are multiple options to create new Ethereum accounts-


• geth console,

• Mist wallet, or

• The basic difference between an account and a wallet is that

• an account is a public-private key pair whereas a wallet hosts account and also provides

• some advanced features such as

• transaction log,

• multisignature options, etc.

• While creating a new Ethereum wallet, a passphrase is normally required.

• During account creation, along with public-private key pair, another phrase gets created
known as mnemonic.

• This mnemonic can be used to recover or import account on a different wallet.

• During Ethereum blockchain transactions, a sender account is required to initiate the


transaction .

• While performing any transaction that changes the state of an event on ethereum
block chain

• Ethereum blockchain, it is required to unlock the sender account.

• This can be done using the key or mnemonic associated with that account.

• There are two types of accounts in Ethereum:

• 1. Externally owned accounts.

• 2. Contract accounts.
My Ether Wallet

• MEW is an easy-to-use,

• open-source platform that allows generation of Ethereum wallet address data about the
generated wallet address gets stored on their platform and account owners have
complete control of the addresses they own.

iv. Truffle framework.

• IT is a suite of tools that assist in setting

• The development environment ,

• testing the smart contract, and

• also serves as asset pipeline for Ethereum.

• it aims to perform a lot of heavy lifting and make Ethereum development easier.
Features of truffle frame work
Unit-5

1) Explain about Interplanetary File system


Ans) Data Storage and Retrieval on IPFS

• IPFS stores data in chunks of size 256 kB known as IPFS Objects (Figure 7.1). This object mainly
contains two fields:

• 1.Data of type Binary Large Objects (BLOU).

2.Links or type array that links to other IPFS objects

• If the file size is more than 256 KB IPFS creats multiple objects till the entire file is
accommodates. In the end, it. creates an empty object which contains just links to all other
objects.
• IPFS stores file contents in an immutable fashion which means when a file is published,

• it is not possible to alter the contents of that file as it changes the hash or content ID of that file.

• The version updates to a file are handled in IPFS using commit objects.

• Whenever a file is added to the network, a commit object is created and when the file is
updated, a new commit object gets created which points to the previous commit object

• In this way, the entire history of a file is available on the network. All these tasks are handled
automatically by the IPFS software.
IPFS Setup and Usage

• The steps involved in setting up IPFS are as follows

1. Download dependencies.

2. Install IPFS.

3. Initialize IPFS -navigate to ipfs binary from a terminal window and run ipfs init command.

This creates a hash for peer identity.

4. Verify initialization by requesting a file [ipfs cat /ipfs/<HASH>/readme].

5. Join IPFS public network [ipfs daemon].

Adding a file
• Navigate co the directory where this file is located and run the command

• ipfs add {path to test.rtf}.

• Once the file is added.

• it displays a confirmation message with the content id or hash value of the file

To view contents of a

To view contents of test.txt file

Type the command ipfs cat<hash value>

The file contents get displayed in the console

You might also like