In this project, I implemented a toy cryptocurrency blockchain from scratch. Here are some details:
- IP addresses of miner nodes are defined in miners.txt file.
- Public keys(Addresses) of miners are defined in genesis block payload.
- Blocks and transactions are signed with RSA public key digital signature scheme.
- Account based transaction format is used.
- REST API is used to interact with the nodes.
- Python
- RSA
- Django
- Django Rest Framework
- Put
*/10 * * * * cd <project path> && /usr/bin/python manage.py mine
python manage.py init
python manage.py runserver 0.0.0.0:8000
-
Method :
GET
-
Path :
/block_count/
-
Response :
{
"block_count": <block_count>
}
-
Method :
GET
-
Path :
/blocks/<block_hash>/
-
Response :
{
"index": 1,
"timestamp": <timestamp>,
"sign": <sign>,
"hash": <hash>,
"previous_hash": <previous_hash>,
"transactions": [<transaction_data>, <transaction_data>, ...],
"payload": <payload>,
"miner": <miner>
}
-
Method :
GET
-
Path :
/transactions/<transaction_hash>/
-
Response :
{
"sender": <sender>,
"receiver": <receiver>,
"amount": <amount>,
"hash": <hash>,
"timestamp": <timestamp>,
"sign": <sign>
}
-
Method :
POST
-
Path :
/new_transaction/
-
Request :
{
"sender": <sender>,
"receiver": <receiver>,
"amount": <amount>,
"hash": <hash>,
"timestamp": <timestamp>,
"sign": <sign>
}
- Create new public address and key pairs :
python wallet.py create_new_wallet
- Send coin :
python wallet.py <public_key_of_receiver> <amount>