Sample Blockchain using Python & Flask
# Importing the required libraries import datetime import hashlib import json from flask import Flask, jsonify # Building a sample Blockchain class Blockchain: def __init__(self): self.chain = [] self.createBlock(nonce = 1, previousHash = '0') def createBlock(self, nonce, previousHash): block = {'index': len(self.chain) + 1, 'timestamp': str(datetime.datetime.now()), 'nonce': nonce, 'previousHash': previousHash} self.chain.append(block) return block def getPreviousBlock(self): return self.chain[-1] def proofOfWork(self, previousnonce): ...