0% found this document useful (0 votes)
25 views36 pages

Smart Contract

Uploaded by

Poornima S
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)
25 views36 pages

Smart Contract

Uploaded by

Poornima S
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/ 36

SMART CONTRACT

Dr. S. Poornima
Why Smart Contracts?

2
What is Smart Contract?

3
What is Smart Contract?

4
What is Smart Contract?

5
Example: Smart Contracts

6
Example: Smart Contract

7
Example: Smart Contracts

8
SMART CONTRACTS

9
BITCOIN vs SMART CONTRACT

10
BITCOIN vs SMART CONTRACT

11
Distributed Program

12
SMART CONTRACTs

13
SMART CONTRACTs

14
DAPPS in Ethereum
• DAPP - decentralized application
• Application that is built for decentralized networks like Ethereum

• Combines two components:


• 1. Smart Contracts
• 2. User interface for executing transactions and contracts

15
Programmatically access Ethereum networks
Ethereum Node

Code

Storage
Smart Contract 1

Ethereum Node Smart Contract 2

Code Accounts
web3.js JSON ‐ RPC geth / Infura
ethers.js Endpoints Storage
Smart Contract 1 Ethereum Node
User Web UI Ethereum
Smart Contract 2
Client/ Node Code

Accounts Storage
DAPP UI
Smart Contract 1

Smart Contract 2

Accounts

Ethereum Network
16
(Mainnet / Testnet)
17
Smart Contracts
• Program that is executed in a decentralized setting.

• Acts on distributed ledger data.

• Output of the program depends on consensus of independent


participants executing it.

18
Ethereum Smart Contracts
• Program that reads data from the Ethereum ledger, performs
operations on it, and writes back the output to the ledger.
• Smart contracts are a type of Ethereum account.
• have a balance
• can send transactions over the network
• not controlled by a user, run as programmed
• User accounts interact with a smart contract by submitting transactions
that execute a function defined on the smart contract.

19
20
Compiler
Deploy
Bytecode Smart Contract
Compiler

Smart Contract Code


• Solidity
• Vyper
Execute

Application Binary
web3.js
Interface (ABI)

https://vyper.readthedocs.io/en/stable/
https://docs.soliditylang.org/en/v0.8.9/
21
Solidity
• High-level language for // SPDX-License-Identifier: GPL-3.0

implementing smart contracts


pragma solidity >=0.8.2 <0.9.0;

/**
• Statically typed * @title Storage
* @dev Store & retrieve value in a variable
• Supports inheritance * @custom:dev-run-script
./scripts/deploy_with_ethers.ts
• Libraries */
contract Storage {

• Complex user-defined types uint256 number;

• Syntax influenced by Javascript and /**


* @dev Store value in variable
C++ * @param num value to store
*/
function store(uint256 num) public {
number = num;
}

/**
* @dev Return value
* @return value of 'number'
*/
function retrieve() public view returns (uint256){
return number;
https://docs.soliditylang.org/en/v0.8.9/ }
}
22
Compiling Solidity
• solc compiler
• Compile .sol files to
bytecode
• Command line tool
• Remix editor
• Browser based
• Compile, emulate, deploy
contracts
• https://remix.ethereum.org/

23
https://docs.soliditylang.org/en/v0.8.9/installing‐solidity.html#installing‐solidity
Simple Storage Contract
// SPDX‐License‐Identifier: GPL‐3.0
pragma solidity >=0.7.0 <0.9.0;
contract Storage {
uint256 positivenumber;
function store(uint256 inputnumber) public {
positivenumber = inputnumber;
}
function readdata() public view returns (uint256){
return positivenumber;
}
}

24
https://docs.soliditylang.org/en/v0.8.9/installing‐solidity.html#installing‐solidity
Dapps (Decentralized apps)

25
Ethereum virtual machines and Gas

• How to handle infinite or very big loops in Ethereum coding


• Virus in form of smart contract
• What happens when smart contracts gain access to private information in
the pc

26
GAS

27
28
Decentralized Autonomous Organizations
(DAOs)
• DAO is an organization in which the decision‐making is not in the hands
of a centralized authority but preferably in the hands of certain
designated authorities or a group or designated people as a part of an
authority
• DAOs rely on smart contracts for decision‐making (governed by the
protocols embedded in a smart contract ), or refered as decentralized
voting systems—within the organization

29
Hard and Soft Fork

30
31
32
33
Challenges and Risks of Smart contract
• Esoteric Programming Languages – difficult to understand for all
• External Data Reliability – third part programs to perform functions
lead to operational risks
• High‐Stakes Flaws – costly errors – loss of users assets
• Relationships and Liability – unresolved legal – if any error, who
responsible and jurisdiction is questionable

34
Summary of smart contracts
Benefits:
• Security
• Transparency
• Free from third party
Uses:
• Intellectual Possessions Rights using NFTs
• Property Rights
• Chain of Custody
• Signatures and Notarization

35
36

You might also like