Distributed Apps (DApps) Prof. Tom Austin San Jos State University - - PowerPoint PPT Presentation

distributed apps dapps
SMART_READER_LITE
LIVE PREVIEW

Distributed Apps (DApps) Prof. Tom Austin San Jos State University - - PowerPoint PPT Presentation

Cryptocurrencies & Security on the Blockchain Distributed Apps (DApps) Prof. Tom Austin San Jos State University Evolution of the Web Web 1.0 Few content creators Web 2.0 User-generated content Social media


slide-1
SLIDE 1

Cryptocurrencies & Security on the Blockchain

  • Prof. Tom Austin

San José State University

Distributed Apps (DApps)

slide-2
SLIDE 2

Evolution of the Web

  • Web 1.0

– Few content creators

  • Web 2.0

– User-generated content – Social media – Applications still centralized

  • Web 3.0

– Decentralized applications

slide-3
SLIDE 3

What Makes a DApp?

  • Smart contracts

–Business-logic, application state, etc. –Replace server-side layer

  • Frontend

–HTML, JavaScript, etc.

– Web3.js – communication with smart contract

  • Other components

–Storage: IPFS or Swarm –Messaging: Whisper

slide-4
SLIDE 4

Taken from Mastering Ethereum

slide-5
SLIDE 5

Advantages of a DApp

  • Advantages:

–Censorship-resistance –Transparency –Resilience

  • Disadvantages:

–Pretty much everything else

slide-6
SLIDE 6

DApp Development Process

  • 1. Compile Solidity code
  • 2. Run Ganache for testing
  • 3. Deploy code
  • 4. Interact through web3.js
slide-7
SLIDE 7

Solidity Compiler

  • Produces:

– EVM bytecode – Application Binary Interface (ABI)

  • Usage:

$solcjs --bin --abi ContractFile.sol

  • Installed through npm.

– NOTE: There are other solidity compilers.

slide-8
SLIDE 8

Solidity Compiler Example

(in class)

slide-9
SLIDE 9

ABI

  • Specifies interface for other

tools to use.

  • Produced by Solidity compiler.
  • Sample (shown in class).
slide-10
SLIDE 10

Ganache

  • "One-click blockchain"

–Blockchain emulator

  • Part of Truffle tool suite
  • Install through npm
  • Creates 10 accounts with 100 ether
slide-11
SLIDE 11

Web3.js

  • Interacts with Smart Contract
  • Works with either node or browser
  • WARNING: a little buggy
slide-12
SLIDE 12

DApp example

(in class)

slide-13
SLIDE 13

Note on Using Strings

  • Many applications use bytes32 rather than

string.

– Lower gas price.

  • Web3.js offers utility functions to convert:

– web3.utils.hexToAscii converts bytes to a string – web3.utils.asciiToHex converts a string to bytes

slide-14
SLIDE 14

Lab: Auction DApp

  • Build a DApp for an auction
  • Details in Canvas