input: 
  import hashlib
  import json
  
  class Blockchain:
  
   def __init__(self):
   self.chain = []
   self.transactions = []
  
   def create_block(self, nonce, previous_hash):
   block = {
   'block_number': len(self.chain) + 1,
   'timestamp': self._current_timestamp(),
   'nonce': nonce,
   'previous_hash': previous_hash
   }
   self.chain.append(block)
   return block
  
   def _current_timestamp(self):
   return round(time.time() * 1000)
  
   def hash_block(self, block):
   string_object = json.dumps(block, sort_keys=True)
   block_string = string_object.encode()
   raw_hash = hashlib.sha256(block_string)
   hex_hash = raw_hash.hexdigest()
   return hex_hash
  
  # Example:
  # blockchain = Blockchain()
  # block = blockchain.create_block(12345, '0000000000000000000000000000000000000000000000000000000000000000')
  # print(blockchain.hash_block(block))
  
output:     
  import time
  
   def add_transaction(self, sender, receiver, amount):
   self.transactions.append({
   'sender': sender,
   'receiver': receiver,
   'amount': amount
   })
  
   def get_last_block(self):
   return self.chain[-1] if self.chain else None
  
   def proof_of_work(self, previous_nonce):
   new_nonce = 1
   check_proof = False
   while check_proof is False:
   hash_operation = hashlib.sha256(str(new_nonce**2 - previous_nonce**2).encode()).hexdigest()
   if hash_operation[:4] == '0000':
   check_proof = True
   else:
   new_nonce += 1
   return new_nonce
  
   def is_chain_valid(self, chain):
   previous_block = chain[0]
   block_index = 1
   while block_index < len(chain):
   block = chain[block_index]
   if block['previous_hash'] != self.hash_block(previous_block):
   return False
   previous_nonce = previous_block['nonce']
   nonce = block['nonce']
   hash_operation = hashlib.sha256(str(nonce**2 - previous_nonce**2).encode()).hexdigest()
   if hash_operation[:4] != '0000':
   return False
   previous_block = block
   block_index += 1
   return True
  