Skip to content

rajasekar-venkatesan/BlockChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

BlockChain

Blockchain implementation in Python

Run servers:

Terminal 1:

python blockchain.py

Terminal 2:

python blockchain.py --port 5001

Terminal 3:

python blockchain.py -p 5002

...

Transaction template:

transaction:

{

'sender': <sender-name/id>,

'recipient': <recipient-name/id>,

'amount': ,

}

HTTP POST Operations

1) Add Transactions:

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"

2) Register Nodes:

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"

GET Operations

1) Mine:

Creates/Mines for a new block with all the transactions since previous block

http://localhost:5000/mine

2) Chain:

Displays the blockchain held by that node

http://localhost:5001/chain

3) Resolve nodes:

Compares a node's own chain with its neighbours' chain and resolve which chain to use.

http://localhost:5000/nodes/resolve

Block template:

block

{

'index': ,

'timestamp': ,

'transactions': [],

'proof': ,

'previous_hash':

}

About

Blockchain implementation in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages