34
Building Ethereum apps (dapps) with... Truffle - build and deploy Ethereum dapps Lightwallet - simple browser wallet IPFS - decentralized file storage BTCRelay - verify Bitcoin transactions

Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Embed Size (px)

Citation preview

Page 1: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Building Ethereum apps (dapps) with... Truffle - build and deploy Ethereum dappsLightwallet - simple browser walletIPFS - decentralized file storageBTCRelay - verify Bitcoin transactions

Page 2: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Building Ethereum apps (dapps) with truffle.readthedocs.io

Page 3: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.io

Deploying Smart Contracts

Page 4: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

DAPP (using Web3.js)

Page 5: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Smart Contract

DAPP (using Web3.js)

Page 6: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP (using Web3.js)

Smart Contract

Page 7: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

DAPP (using Web3.js)

Solidity Compiler

Smart Contract Compiled binary + ABI ABI = Application Binary Interface to variables & functions in the Contract

Page 8: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP (using Web3.js)

Key

Smart Contract

nonce = 0

DAPP pushes compiled contract to network

Compiled binary + ABI

Page 9: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP (using Web3.js)

Key

Smart Contract

nonce = 0

1 2 3

nonces prevent pushing duplicate transactions and increase for the lifetime of a key

DAPP pushes compiled contract to network

Compiled binary + ABI

Page 10: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP (using Web3.js)

Key

nonce = 0

DAPP pushes compiled contract to network

Compiled binary + ABISmart Contract

After Contract posted to

blockchain returns

Address

Address added to ABI

1 2 3 4

Page 11: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP (using Web3.js)

Key

Smart Contract

After Contract posted to

blockchain returns

Address

1 2 3 4

Contract Creation Transaction

Address added to ABI

nonce = 0

DAPP pushes compiled contract to network

Compiled binary + ABI

Page 12: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP (using Web3.js)

Key

nonce = 1

Key

Frontend cannow make calls to contract on blockchain:Address + ABI + nonce

nonce = 0

DAPP pushes compiled contract to network

Smart Contract

1 2 3

After Contract posted to

blockchain returns

Address

4 5

Regular Transactions with Smart Contracts on Blockchain(Ether transfer or Function calls)

Compiled binary + ABI Address added to ABI

Page 13: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP

Key

nonce = 1

Key

Frontend cannow make calls to contract on blockchain:Address + ABI + nonce

nonce = 0

DAPP pushes compiled contract to network

Compiled binarySmart Contract Address + ABI

1 2 3

After Contract posted to

blockchain returns

Address + ABI

4 5

… is a command-line tool to help youcompile, deploy, link and test

smart contracts… and build a front-end

Page 14: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP

Key

nonce = 1

Key

Frontend cannow make calls to contract on blockchain:Address + ABI + nonce

nonce = 0

DAPP pushes compiled contract to network

Compiled binarySmart Contract Address + ABI

1 2 3

After Contract posted to

blockchain returns

Address + ABI

4 5

… is a command-line tool to help youcompile, deploy, link and test

smart contracts… and build a front-end JavaScript, SASS, ES6 and

JSX

Mocha and Chai

Page 15: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Ethereum Node

Ethereum / or Private Network

Solidity Compiler

DAPP

Key Key

Smart Contract

Keystore

Transactions can be signed in the Ethereum Node by Web3.js, or signed in the front-end and pushed to the node as a “raw transaction” (our next topic… :)

All Transactions* must be signed with keys and require gas* any changes to state (writes, etc.)

Compiled binary + ABI Address added to ABI

Page 16: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.io

Installing and Using Truffle

Page 17: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

$ npm -g install truffle

Page 18: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

testrpc $ npm install -g ethereumjs-testrpc

solchttps://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial#using-an-online-compiler

Page 19: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

New truffle project $ mkdir newproj && cd newproj $ truffle init

Creates this in newproj/

Page 20: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.iotruffle.readthedocs.io

Compile smart contracts (do you have solc installed?) $ truffle compile

Deploy smart contract to blockchainRun an Ethereum node (like testrpc)$ truffle deploy

Run truffle tests from test/ directory $ truffle testRun a server from localhost $ truffle serve

Page 21: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

truffle.readthedocs.io

github.com/ConsenSys/truffleQuestions: gitter.im/ConsenSys/truffle

Page 22: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Building Ethereum apps (dapps) with github.com/ConsenSys/eth-lightwallet

Page 23: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

github.com/ConsenSys/eth-lightwallet

A minimal Ethereum browser wallet

Page 24: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

github.com/ConsenSys/eth-lightwallet

Page 25: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

github.com/ConsenSys/eth-lightwallet

Lightwallet FeaturesHD Wallet

- 12 word seed generates HD tree of addresses

- Private key encrypted in browser (+ Password)

- Lost private key? Can regenerate with 12 word seed

External transactions- Transactions not signed by an Ethereum client

- For example using github.com/ConsenSys/hooked-web3-provider

Page 26: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys
Page 27: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys
Page 28: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Building Ethereum apps (dapps) with Ipfs.io (decentralized file storage)

Page 29: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Building Ethereum apps (dapps) with github.com/ethereum/btcrelay

Page 30: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

github.com/ethereum/btcrelay

A relay between Bitcoin and Ethereum

Page 31: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

github.com/ethereum/btcrelay

BTCRelayVerify Bitcoin payments in Ethereum

Available on Morden (Ethereum testnet) or live Ethereum (main net)

Page 32: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys
Page 33: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys
Page 34: Building decentralized applications (dapps) on Ethereum - Eva Shon, & Igor Lilic, ConsenSys

Building Ethereum apps (dapps) with... Metamask.iouPort