Post on 16-Apr-2017
transcript
Building Ethereum apps (dapps) with... Truffle - build and deploy Ethereum dappsLightwallet - simple browser walletIPFS - decentralized file storageBTCRelay - verify Bitcoin transactions
Building Ethereum apps (dapps) with truffle.readthedocs.io
truffle.readthedocs.io
Deploying Smart Contracts
truffle.readthedocs.iotruffle.readthedocs.io
Ethereum Node
Ethereum / or Private Network
DAPP (using Web3.js)
truffle.readthedocs.iotruffle.readthedocs.io
Ethereum Node
Ethereum / or Private Network
Smart Contract
DAPP (using Web3.js)
truffle.readthedocs.iotruffle.readthedocs.io
Ethereum Node
Ethereum / or Private Network
Solidity Compiler
DAPP (using Web3.js)
Smart Contract
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
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
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
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
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
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
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
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
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
truffle.readthedocs.io
Installing and Using Truffle
truffle.readthedocs.iotruffle.readthedocs.io
$ npm -g install truffle
truffle.readthedocs.iotruffle.readthedocs.io
testrpc $ npm install -g ethereumjs-testrpc
solchttps://github.com/ethereum/go-ethereum/wiki/Contract-Tutorial#using-an-online-compiler
truffle.readthedocs.iotruffle.readthedocs.io
New truffle project $ mkdir newproj && cd newproj $ truffle init
Creates this in newproj/
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
truffle.readthedocs.io
github.com/ConsenSys/truffleQuestions: gitter.im/ConsenSys/truffle
Building Ethereum apps (dapps) with github.com/ConsenSys/eth-lightwallet
github.com/ConsenSys/eth-lightwallet
A minimal Ethereum browser wallet
github.com/ConsenSys/eth-lightwallet
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
Building Ethereum apps (dapps) with Ipfs.io (decentralized file storage)
Building Ethereum apps (dapps) with github.com/ethereum/btcrelay
github.com/ethereum/btcrelay
A relay between Bitcoin and Ethereum
github.com/ethereum/btcrelay
BTCRelayVerify Bitcoin payments in Ethereum
Available on Morden (Ethereum testnet) or live Ethereum (main net)
Building Ethereum apps (dapps) with... Metamask.iouPort