A simple implementation of Blockchain in python
- Download the .py file into a folder named 'Code'.
- Download .sh file into the folder in which 'Code' is present.
- run .sh file on terminal by following commands one by one with the port number.
./linknodes.sh 5000
./linknodes.sh 5001
./linknodes.sh 5002
./linknodes.sh 5003
(This will create 4 folders, one for each node, with the .py file saved & synchronized among all) - open Code5000 folder in terminal and run the .py file in it with the node number. Keep the port_number same as that in the folder name and append -m if you want to start mining at that node. If port_number is not specified, the code runs at 5000.
python3 blockchain.py -p <port_number> -m
- Do the same thing with other nodes as well. You will notice that each node shows if the other nodes are running.
- Go to
localhost:5000/blockchain.json
to check the data at the node. You can verify same data exists across all the nodes.
- python3
- flask
- requests
- hashlib
( if you get a ModuleNotFound error, just runpip3 install <module name>
)
- fix hash errors