This is a tentative of implementation of a basic blockchain using Python. The objective is to support an introduction of the elementary components and concepts of a blockchain to a beginner.
The Blockchain is a chain of blocks. Each blocks is represented by several attributes include the list of transaction, a timestamp, a proof and the previous hash of the previous block.
Each block's hash will be generated based on the previous block's hash.
chain
: List of blockspending_transaction
: List of transactions not yet added to a block
new_block
: Method to add each block to the chainnew_transaction
: Method to add a transaction to the list of pending transactionshash
: Method to generate a hash from a blocklast_block
: Method property to get the last block of the chain
- There is no condition to use
new_block
to create a new block. We do not make use of theproof
. - There is no fee for the miners.
- What about: count of transactions, public/private keys, merkle tree structure.