Example #1
0
from wallet import Wallet

my_wallet = Wallet("aymen")
blockchain = BlockChain()

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",
#!/usr/bin/python3

from wallet import Wallet
from chain import BlockChain
from block import Block
#sign transaction
my_wallet = Wallet("A")
b = BlockChain()
my_wallet.create_keys()
my_wallet.save_keys()
my_wallet.load_keys()
pub = my_wallet.public_key
prv = my_wallet.private_key

verf = my_wallet.verify_transaction(b.add_transaction().data[TRANSACTION])

signer = my_wallet.sign_transaction(sender="Ons_Jannet",
                                    recipient="Aymen_Haddaji",
                                    amount=10)

print(" signature user is:", signer, verf)