"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
B4uConference_ethereum
1. How to develop Decentralized
Apps on Ethereum
Thien Nguyen
2. About me
• Native name: Nguyễn Lê Quỳnh Thiện
• From: Vietnam
• Engineering Manager at NashTech
• Founder of SimplCommerce
• Microsoft MVP
• @thiennlq
3. Agenda
• Blockchain – Key points
• Ethereum – Introduction
• DApp – Environment development
• DApp – General architecture
• DApp – Demo building auction application
4. Bitcoin History
• “Bitcoin: A Peer-to-Peer Electronic Cash System” Nov, 2008 by Satoshi
Nakamoto https://bitcoin.org/bitcoin.pdf
• First implementation released in Jan 2009 by Satoshi Nakamoto
11. Blockchains
• Distributed (Everybody keep their own copy of the ledger)
• Transaction immutability achieved by way of blocks & chaining
• Leverages consensus mechanism for validating the transactions
• Uses cryptography for trust, accountability, security
• There is no single point of failure
15. Ethereum Accounts
• Has an address
• Controlled by a private key
• Has an address
• No private key
• Holds and run code
External Owned Account
Contract Account
16. Go Etherum Client
Geth
ÐΞVp2p [TCP, 30303]
> JS API Console
IPC-RPC
WS-RPC [8546]
JSON-RPC [HTTP, 8545]
Disabled by default
Disabled by default
17. Ethereum Networks
• Network Id = 1
• Morden: Network Id = 2 (retired)
• Ropsten: Network Id = 3
• Rinkerby: Network Id = 4
• Kovan: Network Id = 42
• Network Id = Assigned
Live Network
Testnet
Private Network
18. DEMO
Setup a private Ethereum network
https://github.com/devcafevn/ethereum-auction-app/tree/master/private-network
19. Using Ethereum Wallet and MetaMask
Ethereum Wallet MetaMask
You can install the MetaMask add-on in Chrome, Firefox,
Opera
https://github.com/ethereum/mist/releases
21. GAS
• Gas is the unit in which EVM resource usage is measured
• Gas limit (start gas): max amount of gas you willing to spend
• Gas price: price of gas on ether you willing to pay. Miners decides the
minimal acceptable price
Transaction Fee = Gas used * Gas price
Gas used < Gas limit
=> Refund
Gas used > Gas limit
=> Out of gas exception, no change made
22. Remix - https://remix.ethereum.org
• Writing your first smart contract
pragma solidity ^0.4.0;
contract MyAccount {
uint private myBalance;
function MyAccount(uint _myBalance) public{
myBalance = _myBalance;
}
function getBalance() public constant returns(uint){
return myBalance;
}
function add(uint _amount) public returns(uint){
myBalance += _amount;
return myBalance;
}
}
26. Online Auction App
• Everyone can send their bids to a
contract
• The highest current bid is visible
to every one
• At the end of the bidding period
• The highest bid is sent to the
beneficiary
• Other bidders can withdraw their
bids
Image source: https://kryptomoney.com/italian-auction-house-now-accepting-payments-
bitcoins/
Source code: https://github.com/devcafevn/ethereum-auction-app