Blockchain implementation in Python
Terminal 1:
python blockchain.py
Terminal 2:
python blockchain.py --port 5001
Terminal 3:
python blockchain.py -p 5002
...
transaction:
{
'sender': <sender-name/id>,
'recipient': <recipient-name/id>,
'amount': ,
}
Example: To add a transaction to the node in port 5000
$ curl -X POST -H "Content-Type: application/json" -d '{"sender": "sender-name/id", "recipient": "recepient-name/id", "amount": 5}' "http://localhost:5000/transactions/new"
Example: To register a neighbouring node(:5000) with a node(:5001)
$ curl -X POST -H "Content-Type: application/json" -d '{"nodes": ["http://127.0.0.1:5000"]}' "http://localhost:5001/nodes/register"
Creates/Mines for a new block with all the transactions since previous block
Displays the blockchain held by that node
Compares a node's own chain with its neighbours' chain and resolve which chain to use.
http://localhost:5000/nodes/resolve
block
{
'index': ,
'timestamp': ,
'transactions': [],
'proof': ,
'previous_hash':
}