Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ethereum 101

以太坊介紹@中央資管

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

Ethereum 101

  1. 1. g @ncu 2017.01.20 1
  2. 2. $ whoami •  9N J N 和 享 ⽤是 –  3(( N J N ( –  和 享⼩ e⼒ •  z t 也 後 –  3 第⽂ 電 –  ⼒ 給 加 也 第⽂ •  都 d ⽚ ⽚t ⾝ 出 ⽤ –  –  j機 ⼦ •  可⼒ d 實 7:F9 –  FN HGF3 得這 e 也 2 C I B ( B A DB
  3. 3. u •  +))1 ) –  FJ R BJTJ z 同# ⼤ 個本 以 •  +))2 –  ⽤ –  個本 ⽤ –  ) ))) 個本 家fm •  +) ) –  –  3((KR RW P( 3
  4. 4. •  點本 •  本 兩 •  本 明 •  g⼀p果 # 4
  5. 5. b •  w p 點本 多 –  來意 點本 明學 –  來意 點本 名 5
  6. 6. 6
  7. 7. s 7 ⽂ 博 ⽂ Secp256k1
  8. 8. )A Sd D 8 Alice Bob 點本 ~u 明學 來 eh 7UR N
  9. 9. )A Sd D 9 Alice Bob 7UR N ⽂ – 點本 8 K 點本 ~u 明學 來 eh 7UR N 密文
  10. 10. )A Sd D 10 Alice Bob 7UR N p 8 K fm 本e 點本 hu 明學 密文
  11. 11. S y 11 Alice Bob   8 K re 本k來g +   來 7UR N 全 ,   來種 m 本 k 明
  12. 12. y 12 Alice Bob #12344 #12345 n 本 ⼀pfm 新e
  13. 13. P 13 Alice Bob #12345 ⾼ hgh 7UR N e + 7UR N k ⾼ #12345 Alice: 100 -> 99 Bob: 100 -> 101
  14. 14. Recap •  ⽂ –  本 名 –  多eg # •  新 –  沒 本 意 14
  15. 15. ZT •  ⽂ –  本 名 –  多eg # •  新 mlvh果 –  沒 本 意 15 果 全 讓 e全 和 享 8U JRW#
  16. 16. )A Sd D 16 Alice Bob #12345 Alice: 100 -> 99 Bob: 100 -> 101
  17. 17. Double-spending 17 Alice Bob #12345 #12345 Charlie l 來 全
  18. 18. l Xkk 18 Alice Bob #12345 #12345 Charlie ~ 作
  19. 19. 19 Alice Bob #12345 #12345 Charlie klv r 多 博 7UR N 在 e點本 8 K 9 J URN ou沒
  20. 20. 20 Alice Bob #12345 #12345 Charlie 7UR N 種 k點本 +,-. j會 8 K i
  21. 21. Recap •  來意 作 •  全 e 間 •  y l博 多 全 21 Alice 7UR N 有 Sybil aHack
  22. 22. S •  讓 下 h t 讓 •  讓 下 gh t ⻑ 讓 •  讓 下 h fm中 ln –  ⽣全 –  中 le p 22
  23. 23. Proof of Work •  博 多 下 •  多博 們 有 FaKRU J J T# •  ⼤ 的 # 他博 多 •  ⽽ # •  意 全 # 23 和 沒 G
  24. 24. 2D •  mlv~說 D bbUN# –  f v~說 •  gukl ⽣全如 ⽣和 e如 # –  ⽅ 24 r W 45 , el ⽣全
  25. 25. SHA-2562(“abc” + “1”) = 158c09e82d88955d8a051934d12f74a53ea205743778165d1140a8903686e1ac SHA-2562(“abc” + “2”) = c72b0720d3302d76cd7b6b3f3dcb554d05f14fee8567cdda3ee8b7ff51e02015 . . . SHA-2562(“abc” + “19”) = 005eR2ff3e871185b95bf7c8628e212d15a7d08c42235a381e06caa55856a0c 2D •  ⽽ 博 多 很分 25 Hash(TXs+nonce) < number 00000000000000005b95bf7c8628e212d15a7d08c42235a381e06caa55856a0c
  26. 26. SHA-2562(“abc” + “1”) = 158c09e82d88955d8a051934d12f74a53ea205743778165d1140a8903686e1ac SHA-2562(“abc” + “2”) = c72b0720d3302d76cd7b6b3f3dcb554d05f14fee8567cdda3ee8b7ff51e02015 . . . SHA-2562(“abc” + “19”) = 005eR2ff3e871185b95bf7c8628e212d15a7d08c42235a381e06caa55856a0c 2D •  ⽽ 博 多 很分 26 算力越強的人越有機會擁有寫帳權 但不代表掌握 70% 算力別人就沒機會,只是概率低
  27. 27. a 27 Alice #12345 #21397 #81345 #22345
  28. 28. 28 Block 1 ... Block 2 ... Block 3 ... Block 4 ... r和 Hash( Block 3 | TXs | nonce) o e 區塊
  29. 29. AD @ C 29 Block 4 ... Block 5 ... Block 6 ... Block 7 ... Block 8 ... Block 9 ... NJW3 c ) 地 D R W MR RK R W# Block N ... ……… 困難度 (Difficulty) 區塊高度 (Block height) 區塊深度 (Block depth) w m h
  30. 30. Recap •  來意 作 –  D 作 ⽅ –  多博 信r想m為 –  有下 看 ⾏⽔ j •  全 e 間 •  y l博 多 全 30 Alice 7UR N 有
  31. 31. Blockchain •  Demo 31
  32. 32. Ethereum 101 32
  33. 33. cWP Ethereum? 33 Vitalik Buterin “Bitcoin was designed to be a SMTP. It’s a protocol that is very good at one paracular task. It is good for transferring money, but it was not designed as a foundaaonal layer for any kind of protocols to be built on top.”
  34. 34. cWP Ethereum? 34 Vitalik Buterin “The need for a technology that was more expansive, and that replicated the funcaonality of Turing-complete programming languages in a way that would be so powerful as to describe any blockchain applicaaon.”
  35. 35. Bitcoin Ethereum Creator Satoshi Nakamoto Ethereum Player type cryptocurrency Smart contract platform with own cryptocurrency Liquidity decent decent currency code Bitcoin/ /BTC Ether/ /ETH Public/Private blockchain public public User identity pseudonymous pseudonymous Consensus algorithm PoW PoW/PoS/Casper Scripting language Bitcoin Script Language Solidity Smart contracts yes (limited) yes Turing completeness no yes Governance (development decisions, etc) Core team Ethereum Foundation Transaction speed >10.0m 15s Rapid payments Lightning Network Raiden Network Processing cost (CPU,GPU,ASIC) high high Other features UTXO GHOST 35
  36. 36. Components •  A cryptographic token •  An address system •  A network of validators (miners) •  A consensus algorithm •  A blockchain ledger •  The Ethereum Virtual Machine •  A set of programing languages •  Complex economic structures 36
  37. 37. Technology Stack (1/2) 37 •  Full node –  go-ethereum (Golang) –  Parity (Rust) –  cpp-ethereum (C++) –  EthereumJ (Java) –  pyethereum (Python) –  ruby-ethereum (Ruby)
  38. 38. Technology Stack (2/2) 38 •  Smart contract programming –  Solidity (JavaScript-like) –  Serpent (Python-like) –  LLL (Lisp-like) –  Viper –  Bamboo
  39. 39. ru t •  Ethereum has a blockchain •  Ethereum is public and permissionless •  Ethereum has Proof-of-Work (PoW) mining –  Ethash •  Ethereum has an inbuilt cryptocurrency (Ether) 39
  40. 40. ru t •  Ethereum’s block ame is shorter (15 seconds) •  Ethereum has smaller blocks –  2,000,000 gas per block –  Limited by the gas à (2,000,000/x) transacaons •  The Ethereum Virtual Machine can run smart contracts •  ETH token issuance 40
  41. 41. ETH token issuance G JU G 5 D N RWN 8U T N J M HW UN N J M HW UN NON NW RWP N J M •  D N RWN3 太還沒 0+)) m 本 有 e g fe太還 要 1)) m 本 •  8U T N J M3 們 fm和 的 h.m 本 fm和 e ⼿ -動 家發 f k++. m和 ,/. +- /) /)( -# +. m 本 •  HW UN N J M3 j z k 和 j f gh j 享s 裡 HW UN和 個本ze 和 C JW KU T# 和 ~ e和 說了 和 e的 的 e 要 . 0(1#5- ,0.m 本 HW UN和 e沒 ⽅ f ⼿k 0)) m 本 •  HW UN NON NW RWP N J M3 jHW UN和 e和 ) . 本 f# •  的 e= U . NNMa NJ RN 1K N NM K NN#41
  42. 42. 圖片來自 https://bitsonblocks.net 42
  43. 43.   沒 ⽂ /- ( ,+ Ka N # +   ⽂ 到 9:F7 下 +1 ( /- Ka N # ,   -) (+) Ka N # –  /- Ka N –  – J J e成下 @N JT +./ J J ,+ Ka N –  ,+ Ka N e + Ka N 現 於 e +) Ka N oh -) # •  N WJU JMM N N # •  ⼿ 9 W J JMM N N # 43
  44. 44. Timeline 44   H r E H pn lO   ,D )HH @ +1, DE D B GE
  45. 45. 45 hHps://etherscan.io/block/3000000
  46. 46. 46 hHps://etherscan.io/block/3000000 hHps://etherscan.io/tx/0xb95ab9484280074f7b8c6a3cf5ffe2bf0c39168433adcdedc1aacd10d994d95a
  47. 47. Ether & Gas •  Ether: token •  Gas: computaaon cost 47
  48. 48. Gas •  n所 多 JW J R W# 看 ⼿ W J # j N N s 主 e 要y m 樣看y m ⼀p⾞ e 因時 fm vu ⾞ e PJ 明每e ⼀p ⾞事ye 下 ⼀e PJ •  PJ m 有 h p種 ⼿~ gu e ⾞ 48
  49. 49. Gas •  j 8R RW z f⾼ 多⼀p 所 hx 多et JW J R W RbN#因 j N N e e 下 j和 享 s ⼀pe •  n j N N z m ⼿ ⽤ t g k ~ e⽤ ⾞ e PJ 主 e y 定r J,因 j 8R RW 多就才e y et t 事 49
  50. 50. 50 Total cost = gasUsed * gasPrice
  51. 51. Gas price •  PJ R N m PJ 上 y N N PJ R N u能這 ⼀不被 •  PJ R N e h NR NR 5 ) 1 N N •  PJ R N e 之 51
  52. 52. 52
  53. 53. 53 韩梅梅 李雷 0.319 BTC Fees 0.001 BTC 0.32 BTC 1AnLpMkAmf7jy2BNkP3oYw1phzhNuLws7M (0.32 BTC) 1GJYiog3ato17SSTFCCdkZ44H6LdkW9j1V (0.319 BTC) Tx Fee: 0.001 BTC u Bitcoin Unconfirmed Transacaon ( ) !!!
  54. 54. 54 { "hash":"7c4025...", "ver":1, "vin_sz":1, "vout_sz":1, "lock_ame":0, "size":224, "in":[{ "prev_out":{ "hash":"2007ae...", "n":0 }, "scriptSig":"304502... 042b2d..." }], "out":[{ "value":"0.31900000", "scriptPubKey":"OP_DUP OP_HASH160 a7db6f OP_EQUALVERIFY OP_CHECKSIG" }] } metadata Input(s) output(s) •  交易 ID (流水號) •  版本 •  Input 數量 •  output數量 •  區塊鎖定時間 •  交易大小 hHps://blockchain.info/rawtx/7c402505be883276b833d57168a048cfdf306a926484c0b58930f53d89d036f9
  55. 55. 55 { "hash":"7c4025...", "ver":1, "vin_sz":1, "vout_sz":1, "lock_ame":0, "size":224, "in":[{ "prev_out":{ "hash":"2007ae...", "n":0 }, "scriptSig":"304502... 042b2d..." }], "out":[{ "value":"0.31900000", "scriptPubKey":"OP_DUP OP_HASH160 a7db6f OP_EQUALVERIFY OP_CHECKSIG" }] } metadata Input(s) output(s) hHps://blockchain.info/rawtx/7c402505be883276b833d57168a048cfdf306a926484c0b58930f53d89d036f9 •  之前的交易 ID (pointer) •  第幾個 ouput •  簽名 scriptSig: <sig> <pubKey>
  56. 56. 56 { "hash":"7c4025...", "ver":1, "vin_sz":1, "vout_sz":1, "lock_ame":0, "size":224, "in":[{ "prev_out":{ "hash":"2007ae...", "n":0 }, "scriptSig":"304502... 042b2d..." }], "out":[{ "value":"0.31900000", "scriptPubKey":"OP_DUP OP_HASH160 a7db6f OP_EQUALVERIFY OP_CHECKSIG" }] } metadata Input(s) output(s) hHps://blockchain.info/rawtx/7c402505be883276b833d57168a048cfdf306a926484c0b58930f53d89d036f9 •  轉出金額 •  bitcoin script
  57. 57. 57 { "hash":"7c4025...", "ver":1, "vin_sz":1, "vout_sz":1, "lock_ame":0, "size":224, "in":[{ "prev_out":{ "hash":"2007ae...", "n":0 }, "scriptSig":"304502... 042b2d..." }], "out":[{ "value":"0.31900000", "scriptPubKey":"OP_DUP OP_HASH160 a7db6f OP_EQUALVERIFY OP_CHECKSIG" }] } metadata Input(s) output(s) hHps://blockchain.info/rawtx/7c402505be883276b833d57168a048cfdf306a926484c0b58930f53d89d036f9
  58. 58. 58 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <sig> a7db6ff121871c65a8924b8e40f160d385515ad7
  59. 59. 59 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <sig> a7db6ff121871c65a8924b8e40f160d385515ad7 <pubKey>
  60. 60. 60 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <sig> a7db6ff121871c65a8924b8e40f160d385515ad7 <pubKey> <pubKey>
  61. 61. 61 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <sig> a7db6ff121871c65a8924b8e40f160d385515ad7 <pubKey> <pubKeyHash>
  62. 62. 62 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <sig> a7db6ff121871c65a8924b8e40f160d385515ad7 <pubKey> <pubKeyHash> <pubKeyHash>
  63. 63. 63 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <sig> a7db6ff121871c65a8924b8e40f160d385515ad7 <pubKey>
  64. 64. 64 scriptSig: <sig> <pubKey> scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG True a7db6ff121871c65a8924b8e40f160d385515ad7
  65. 65. Turing-complete programming languages 65
  66. 66. cWP •  ) –  ( –  –  •  •  •  ( –  –  66 圖片來自 https://bitsonblocks.net
  67. 67. ir 67 •  合約的執行會依據不同時間的事件或設定的規則,而更新狀態或價值
  68. 68. Blockchain is the Internet's society, and smart contracts are its laws.
  69. 69. 70
  70. 70. •  f –  ⼈ N N URNW –  URMR a ⽣ ⼿ –  URMR a RUN –  NK, S ⼿在 更 •  ⼀pk年 享看 享 年 # •  前每 71 •  Full node –  go-ethereum (Golang) –  Parity (Rust)
  71. 71. Truffle + Testrpc •  Truffle –  hHps://github.com/ConsenSys/truffle •  Testrpc –  hHps://github.com/ethereumjs/testrpc •  ⾼ –  hHps://cl.ly/iqCw/ETH_dev.html –  hHps://cl.ly/i7Sd/truffle.html •  g⼀p更開 分為 •  j 年 主 ⼿ •  分 •  說對 BR T e⾼ t ⽤ # –  3(( NMR (6 NM T 72
  72. 72. 73
  73. 73. Data carrier for DApps 74 •  Oraclize: hHp://www.oraclize.it/ –  hHps://github.com/oraclize/ethereum-examples/tree/master/solidity • 
  74. 74. Ethereum Alarm Clock •  Schedule transacaons to be executed at a later ame. •  Enare service operates as smart contracts on the Ethereum blockchain, with no priviledged access given to any party. –  hHp://www.ethereum-alarm-clock.com 75
  75. 75. Ethereum ComputaSon Market •  The computaaon market is a service for Ethereum that allows for verifiable off-chain execuaon of computaaons that would be otherwise prohibiavely expensive to execute within the EVM. –  hHp://www.ethereum-computaaon-market.com 76
  76. 76. zeppelin-solidity •  A Framework to Build Secure Smart Contracts –  Common contract security paHerns –  In the Solidity language –  hHps://openzeppelin.org 77
  77. 77. Ethereum Dev (1/2)   無開 N N ⽂k享 +   m W MN ,   ⾯ PN J JF R 9 W UN -   開 全 開 多 KU T .   ⽂k享e RWN /   ED9 U 到 0   N N 8U T N U N 1   F J 9 W J W N N 2   AR )   F URMR a   :7 P J RWP 78
  78. 78. Ethereum Dev (1/2) •  Track 1 1.  Introducaon to Smart Contracts 2.  Seng up the development environment with truffle and testrpc 3.  Reading documentaaon and reference resources 4.  Watching tutorials on building Smart Contracts 5.  Smart contract security and tesang •  Track 2 1.  Seng up a development environment with ReactJS and Firebase 2.  ReactJS and firebase Hello World 3.  Research on Ethereum and Dapp 4.  Development of a non-trivial Smart Contract Applicaaon 5.  Building user-centric interfaces 6.  Should have a keen interest on building beauaful yet simple UI 79
  79. 79. •  三以 –  hHp://gavwood.com/Paper.pdf •  可 –  hHps://github.com/EtherTW/Taipei-Ethereum-Wiki/wiki/Learning-Resources •  成過 –  hHps://www.youtube.com/channel/UC8CB0ZkvogP7tnCTDR-zV7g/videos 80
  80. 80. g •  GJR NR N N ANN –  3(( NN (GJR NR N N ANN ( •  <J NK T –  3(( OJ NK T (P (--,0. )0+-1-0,2( 81
  81. 81. Q & A Thanks for your listening! 82

×