This is a straightforward decentralized voting system leveraging blockchain technology with an emphasis on security. Each individual is granted a single voting right associated with their unique ID. The system guarantees the synchronization of node information, ensuring all nodes are updated. Nodes are multifunctional, serving either as a voting or mining system. The network is implemented using Flask framework.
To connect all other nodes to the network, a primary node is employed. Upon startup, a new node transmits its details to the primary node.
{
"index": 2,
"previous_hash": "<hash value>",
"proof": 35293,
"timestamp": 1644346339.117375,
"votes": [
{
"person_id": "<hash value>",
"vote": "100"
}
]
}
Begin by ensuring that the following packages are installed:
pip3 install -r req.txt
Next, execute the application:
python3 main.py
Lastly, input your host address and port, for instance:
Host: 127.0.0.1
Port: 5050
To register your device as a node with the blockchain, send a GET request to your device as follows:
import requests
requests.get('http://<your-host>:<your-port>/init')
Alternatively, this can be done using Postman.
You can interact with your node by sending HTTP requests to it.
Address: /nodes
Method: GET
Parameters: None
Address: /current-votes
Method: GET
Parameters: None
Address: /chain
Method: GET
Parameters: None
Address: /update-block
Method: GET
Parameters: None
Address: /mine
Method: GET
Parameters: None
Address: /count-votes
Method: GET
Parameters: None
Each individual's ID is hashed and added to the blockchain. Votes are submitted in the following format:
'1001'
Signifying the first and last individuals who have cast their votes. To add a new vote:
Address: /new-vote
Method: POST
Parameters: {
'person_id': id,
'vote': vote,
}