This is a simple cryptocurrency using Blockchain. There are three nodes, and each one has different port so that it can communicate with other nodes via Flask. API request can be tested on Postman. You can make transactions and mine them as well. Unlike actually cryptocurrency, you need to manually update each nodes if any changes are made such as new blocks are mined or transactions are made.
You need a python version 3.0 or higher
Followin modules should be installed
pip install Flask==0.12.2
pip install requests==2.18.4
Open up three different terminals to run all of three guncoin files
python3 guncoin_node_8080.py
python3 guncoin_node_8081.py
python3 guncoin_node_8082.py
If port 8080,8081,8082 does not work on your local machine, you can replace them with
5000,5001,5003.
In this case, you should customize all of guncoin files.
app.run(host = '0.0.0.0', port = CHANGE THIS SECTION WITH RIGHT PORT)
You need to use postman to deal with API requests.
While terminals are running, open up Postman.
You need a following line to check out the status of current chain of the node.
https://HOSTNAME:PORT_OF_NODE/get_chain
You need following lines to connect each nodes.
https://HOSTNAME:PORT_OF_NODE_1/connect_node
with the body of(raw JSON type) :
{
"nodes": ["https:/HOSTNAME:PORT_OF_NODE_2",
"https:/HOSTNAME:PORT_OF_NODE_3"
]
}
You need to do simiar process to two other nodes to connect entire nodoes
Actually this request should only handle a mining process but, for a testing purpose,
mine_block
request on this code add a sinlge transaction.
When you mine a block, entire current transactions are going to added in the block.
And then the transaction list goes to empty.
You need following lines to mine a block.
https://HOSTNAME:PORT_OF_NODE/mine_block
You need to execute this request to update other nodes.
https://HOSTNAME:PORT_OF_NODE/replace_chain
You need to execute this request to add a transaction.
https://HOSTNAME:PORT_OF_NODE/add_transaction
with the body of(raw JSON type) :
{
{
"sender": "SENDER_NAME",
"receiver": "RECEIVER_NAME",
"amount": AMOUNT_OF_MONEY_TO_SEND
}
}
- **Geon Yoon ** - Initial work - GeonYoon