A blockchain-based application in python.
$ pip install -r requirements.txt
export FLASK_APP=node_server.py
flask run --port 8000
Now one instance of our blockchain node is now up and running at port 8000.
python run_app.py
The application should be up and running at http://localhost:5000.
Here are few screenshots for the application :
Now for settting up multiple Nodes , and registering them we will be using the register_with/
We will be using cURL requests to register the nodes at port 8001
and 8002
with the already running 8000
.
flask run --port 8000 & flask run --port 8001
curl -X POST \
http://127.0.0.1:8001/register_with \
-H 'Content-Type: application/json' \
-d '{"node_address": "http://127.0.0.1:8000"}'
Now node at port 8000 is aware about nodes at port 8001 and 8002. Now there will be an active participation in mining process and sync in all nodes.
Once all of this done, we can run the application , create transactions (post messages via the web interface), and after mining the transactions all the nodes in the network will update the chain. So now even if we will make two transactions , one with port 8000 and second with port 8001 , we will be able to see both transactions in our blockchain. Transaction 3,4 were done with port 8001, but since it is registered with port 8000 , we will see chain the transactions mentioned with port 8000 , and 8001 mentioned as peer.
We can see the chain of nodes by the following command :
curl -X GET http://localhost:8000/chain
Screenshot of the chain of nodes for out current transactions is :