input: import hashlib
  import json
  import time
  
  class Blockchain:
      """Create a basic blockchain in Python using only the core modules.
      Example:
      b = Blockchain()
      block = b.create_block(0, '0')
      print(b.hash_block(block))  # This will print the hex hash of the newly created block
      """
  
      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
output:     
      def add_transaction(self, sender, receiver, amount):
          transaction = {
              'sender': sender,
              'receiver': receiver,
              'amount': amount,
              'timestamp': self._current_timestamp()
          }
          self.transactions.append(transaction)
          return transaction
  
      def mine_block(self):
          if not self.transactions:
              return None
  
          previous_block = self.chain[-1] if self.chain else {'block_number': 0, 'hash': '0'}
          previous_hash = self.hash_block(previous_block)
          nonce = self._proof_of_work(previous_hash)
          block = self.create_block(nonce, previous_hash)
          block['transactions'] = self.transactions
          self.transactions = []
          return block
  
      def _proof_of_work(self, previous_hash, difficulty=4):
          nonce = 0
          while self._valid_proof(nonce, previous_hash, difficulty) is False:
              nonce += 1
          return nonce
  
      def _valid_proof(self, nonce, previous_hash, difficulty):
          guess = f'{nonce}{previous_hash}'.encode()
          guess_hash = hashlib.sha256(guess).hexdigest()
          return guess_hash[:difficulty] == "0" * difficulty
  