This repository is a compilation of very simple implementations in Python of a blockchain for educational purposes.
You can run any of these blockchain code examples directly with the Python interpreter:
$ python blockchain.v1.py
Name | Lines of Code | Features | Limitations | Requirements |
---|---|---|---|---|
blockchain.v1.py | 55 |
|
|
None |
Simplest implementation of all, introduces the notion of blockchain as a chain of blocks (locally stored in an array) and the concept of hashing. There is one single node that generates a first set of 20 blocks at once, and prints them out. It's worth noticing that when you run this same script multiple times, you always get different hashes for the same block in the chain, despite the fact that the blocks are generated in a deterministic manner. Why? Because the hash includes the timestamp of each block, which is always different from the last time you run the same script.
Credit: aunyks and his original Medium article, and JohnStuartRutledge for the Python3 version