#!/usr/bin/python3 from chain import BlockChain from wallet import Wallet from transactions import Transaction bch = BlockChain() w1 = Wallet("Abdou") w2 = Wallet("Aymen") tr = Transaction(w1, w2, "50000") late = bch.latest_block bch.construct_block(late.proof_nonce, late.prev_hash, tr.to_dict(), { w1.user_id: "00", w2.user_id: "00" }) tr1 = Transaction(w2, w1, "50000") late = bch.latest_block bch.construct_block(late.proof_nonce, late.prev_hash, tr1.to_dict(), { w1.user_id: "00", w2.user_id: "00" }) w3 = Wallet("Ons") bch.construct_block(late.proof_nonce, late.prev_hash, [], { w1.user_id: "00", w2.user_id: "00", w3.user_id: "00" }) print(bch.chain)
print("Blockchain Records Status :") print(blockchain.chain) last_block = blockchain.latest_block last_proof_nonce = last_block.proof_nonce proof_nonce = blockchain.proof_of_work(last_proof_nonce) print("***Mining CyberCellCoin about to start***") blockchain.add_transaction( sender="Ons_Jannet", #it implies that this node has created a new block recipient="Aymen_Haddaji", #let's send Aymen some coins! amount=10, #creating a new block (or identifying the proof number) is awarded with 10 ) last_hash = last_block.calculate_hash block = blockchain.construct_block(proof_nonce, last_hash) print(blockchain.chain) print("***Transaction seccessfully executed***") print("===============================================") print("let's execute another transaction !") print("===============================================") blockchain.add_transaction( sender="Ons_Jannet", recipient="Abdou_Hidoussi", amount=15, ) last_hash = last_block.calculate_hash block = blockchain.construct_block(proof_nonce, last_hash) print(blockchain.chain)