The following contains a Python implementation of a basic blockchain
The implementation consists of three files:
blockchain.py.block.pymain.py
There are two unit-test files:
block_test.pytests the transaction functionalityblockchain_test.pytests theadd_blockandvalidate_blockfunctionality.
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