羅德興老師的教學歷程檔案 - 112-2 Blockchain - 隨堂作業 |
|
|
隨堂作業作業 1: Learn Bitcoin’s underlying data structure in 4 short stepshttps://colab.research.google.com/drive/1fBgGiBMg25H-_7GtWX-MOLH3jmR0yiOe?usp=drive_link作業 2: 50 行 Python 程式代碼構建一個區塊鏈 https://colab.research.google.com/drive/1iqJevUk4Q_lu-NS465XdXqmqJbdpgj-b?usp=drive_link作業 3: 建立自己的區塊鏈 [LINK] # source https://github.com/howCodeORG/Simple-Python-Blockchain/blob/master/blockchain.py import datetime import hashlib class Block: blockNo = 0 data = None next = None hash = None nonce = 0 previous_hash = 0x0 timestamp = datetime.datetime.now() def __init__(self, data): self.data = data def hash(self): h = hashlib.sha256() h.update( str(self.nonce).encode('utf-8') + str(self.data).encode('utf-8') + str(self.previous_hash).encode('utf-8') + str(self.timestamp).encode('utf-8') + str(self.blockNo).encode('utf-8') ) return h.hexdigest() def __str__(self): return "Block Hash 區塊 哈希值: " + str(self.hash()) + "\nBlockNo 區塊編號: " + str(self.blockNo) + "\nBlock Data 區塊資料: " + str(self.data) + "\nHashes 哈希值: " + str(self.nonce) + "\n--------------" class Blockchain: diff = 20 maxNonce = 2**32 target = 2 ** (256-diff) block = Block("Genesis") # 創世區塊 dummy = head = block def add(self, block): block.previous_hash = self.block.hash() block.blockNo = self.block.blockNo + 1 self.block.next = block self.block = self.block.next def mine(self, block): for n in range(self.maxNonce): if int(block.hash(), 16) <= self.target: self.add(block) print(block) break else: block.nonce += 1 blockchain = Blockchain() max=3 print("Print My name 這是 學號 111xxxxxx 姓名 羅老師 的區塊鏈 將會建立 %s 個區塊 \n\n" %(str(max))) for n in range(max): print('Enter your data 請輸入您的區塊內容:') x = input() temp ="Block " + str(n+1) +":" + x blockchain.mine(Block(temp)) print("Print all the blockchain 列印出目前的整個區塊鏈......\n\n") while blockchain.head != None: print(blockchain.head) blockchain.head = blockchain.head.next 作業 4: 區塊鏈應用與分析隨堂作業 (download) NO: NAME: Coding Tech (2018). Blockchain Technology Explained (2 Hour Course) 觀看後作業 https://www.youtube.com/watch?v=qOVAbKKSH10 [LINK] 一、請以一句話說明下列名詞 1. Blockchain evolution 2. Decentralized web 3. Distributed organizations 4. Distributed ledger 5. Smart contracts 6. Distributed applications 7. Internet of value 8. Token economies 二、請寫下或繪出你觀看後的心得或提問 作業 5: 5-0 台灣金融研訓院 TABF Channel Cheap教你金融科技力 (3~4 mins) https://www.youtube.com/playlist?list=PL9NZYNTi48oAD6_uj2aNLK4zFmpKZ5sxj 5-1 How To Become A Blockchain Developer In 2023? https://www.youtube.com/watch?v=lg5ikF8k6yc 5-2 Blockchain Technology Simply Explained (2023) https://www.youtube.com/watch?v=QJn28fFKUR0 5-3 什麼是區塊鏈blockchain? ~~~淺談 區塊鏈的未來發展和應用 (2023, 01'49") https://www.youtube.com/watch?v=KnUpGADFSt4 5-4 最強應用場景 DeFi (2021, 07'52") https://www.youtube.com/watch?v=ti0r4DtZPnw 5-5 https://www.youtube.com/watch?v=L92bh-KJJhY |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
登入帳號密碼代表遵守學術網路規範 |
文章分類 Labels |
最新文章 Top10 |
中華科技大學數位化學習歷程 - 意見反應 |