Workshop 主辦:政大金融科技研究中心 謝明華 老師
一.PM:
梁智程
二.講師:
王銘德、陳昶吾、謝咏宸、梁智程
三.助教:
李宜熹
四.需求:
4/28、4/29 辦 workshop ,只介紹智能合約,每天六小時,要有一天上機實做
五.課程大綱
時間 | 4/28 | 4/29 |
8:20~12:00 | 區塊鏈與以太坊初探 by 昶吾 | 合約與應用程式 by 智程 |
13:20~17:00 | 智能合約介紹 by 銘德 | 智能合約進階開發 by 咏宸 |
每日時間表:
8:20~9:20 Session 1
休息 20 min
9:40~10:40 Session 2
休息 20 min
11:00~12:00 Session 3
午餐 1 hr 20 min
13:20~14:20 Session 4
休息 20 min
14:40~15:40 Session 5
休息 20 min
16:00~17:00 Session 6
六.課程細節規劃
區塊鏈與以太坊初探
- 講者:陳昶吾(3hr)
- 目的:擁有所有撰寫智能合約所需先備知識、對網路與鏈有正確認知
- 內容:
Section 1:
- 什麼是區塊鏈?
- 比特幣介紹
- 以太坊介紹(設計目的、gas 概念)
- 以太坊與其他區塊鏈平台(Corda, Fabric)介紹
Section 2:
- Blockchain Demo 101
- https://github.com/anders94/blockchain-demo
- 共識機制比較 (mining)
- 交易生命週期
- 區塊鏈研究挑戰
- 效能
- 隱私
- 區塊鏈治理
Section 3:
- 了解怎麼建立自己的虛擬貨幣, 配合 imtoken,開 Ethereum 轉帳
- DApp 與一般應用程式的不同處
- 目前受歡迎的 DApp 應用
實作:
- 用 imToken , 開 Ethereum 帳戶轉帳
- uPort Demo
智能合約介紹
- 講者:王銘德 (3hr)
- 目的:熟悉開發工具與 Solidity 用法
- 內容:
Section 1: 設定開發環境,開發工具介紹
- 開發工具
- Metamask
- Mist (*)
- Geth (geth –dev) (https://www.youtube.com/watch?v=cOwlFRQ-aLU&t=170s)
- Solidity online editor
- Devtool (web3.js) (初階)
- Ethereum node:
- Parity
- TESTRPC
- 架設私有開發環境
- Mist 架設
- Geth 私有鏈
實作:
- Token 部署
Section 2: Solidity 合約語言介紹
- 物件導向程式語言
- 型態
- Value Types
- 處理「是或否」用 Boolean
- Solidity 只有整數
- Address 以及底下的 balance 與 transfer
- Fixed-size byte arrays & Dynamically-sized byte array
- Rational and Integer Literals
實作 :
- Hello world smart contract
Section 3: Solidity 合約語言介紹(續)
- Reference Types
- Data location
- Array
- Structs
- Mappings
- 函數 Function
- 例外狀況處理 Exception
- 閱讀官方說明文件
實作 :
- Greeting smart contract
合約與應用程式
- 講者:梁智程 (3hr)
- 目的:能夠端到端完成一個良好使用者體驗的 DApp
Section 1:
- 建立前端到後端完整的一個合約應用
- HTML, js, css
Section 2:
- Dapp 的 UX
- https://medium.com/design-ibm/blockchain-design-principles-599c5c067b6e
- https://github.com/ConsenSys/Ethereum-Development-Best-Practices/wiki/Dapp-Architecture-Designs
Section 3:
- 已有的 Dapp
- Carbon Vote: http://carbonvote.com/
- Ethereum Name Service Registrar DApp https://github.com/ethereum/ens-registrar-dapp
- https://chainy.info/
驗證:
- 完成一個小 Dapp
智能合約進階開發
- 講者:謝咏宸 (3hr)
- 重要 Component: Oracle
- 重要 Component: Standardized token
- Transaction data decode
- Data analysis
- 開發技巧與誤區
- Gas usage (gas cost 表, loop)
- Storage type
- Event, callback
- Security issue
- Key word: public, internal, payable, const, …
- Pattern
- 設計模式(https://arxiv.org/abs/1703.06322 ):4.1 提到的九種
驗證:
- Crowdfunding
- Project (Storage, keyword)
- Receipt (Standardized token, security issue)
- Refund (success -> owner, fail -> user) (gas usage, event)
七.事前準備
課前問卷
- 目的:了解學員先備知識
- 範例:是否具有基礎網路概念、編寫程式經驗
- https://docs.google.com/forms/d/1m6vvR5q8K8xEUoVxhznNjloFl9wv24-DhF6Xyd4JIfk/edit
課前作業
- 目的:補足先備知識
- 下載 Mist 錢包以便實作使用
- 操作說明 https://docs.google.com/document/d/15WFxqEh3buiW9LHqLZsNmwWzTksLSVa-VSgvLc3-njM/edit#heading=h.e72c6nc69h5y
課後專案
- 目的:能夠持續學習
- 範例:觀察某契約專案
- Ether 卡:每位學員價值 100 台幣的 Ether