The following contains a Python implementation of a basic blockchain
The implementation consists of three files:
blockchain.py
.block.py
main.py
There are two unit-test files:
block_test.py
tests the transaction functionalityblockchain_test.py
tests theadd_block
andvalidate_block
functionality.
collections.defaultdict
and uuid
are the two only dependencies, both of which which are standard lib.
The main executable is in main.py. so just run $ python3 main.py
to see an initial run of the transactions. Feel free to add commands in the main
function to try out my implementation.
You can run all tests by running:
python3 block_test.py && python3 blockchain_test.py