- Notifications
You must be signed in to change notification settings - Fork2
Simple blockchain implementation using python and flask. It implements basic concepts of blockchain, like proof of work, mining, consensus, generating and validating the signature on transaction etc.
Adiprogrammer7/blockchain_implementation
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Simple blockchain implemetation with python! Though it won't transfer anything actual to a given address but it implements all the basic concepts of blockchain likeproof of work, mining, consensus, generating and validating signature on transaction etc. The best way of understanding the blockchain is by building one!
First download the repo on your local machine using git clone:
git clone https://github.com/Adiprogrammer7/blockchain_implementation.gitThen navigate to repo and install dependencies:
pip install -r requirements.txtIn theconfig_peers.py add the peers you wish to have while running the network. By default we have some peers added to file like:
# store all url's running on the network here in string format, so that they can communicate# for example: 'http://127.0.0.1:5000/'peers = {'http://127.0.0.1:5000/', 'http://127.0.0.1:5001/'}We will need a valid private key and public key pair to be able to sign the transaction and make a valid transaction. For that you can rungenerate_wallet.py filewhich will give you a valid private key and public key pair.
Now to run, open two terminals and navigate both to repo. Use following commands to run instances of our application:
For the first instance on port 5000:
set FLASK_APP=main.pyflask run --port 5000 --debugger --reloadFor the second instance on port 5001:
set FLASK_APP=main.pyflask run --port 5001 --debugger --reloadNow we will have two instances running onhttp://localhost:5000 andhttp://localhost:5001.
You can find private key and public key pair inwallet.txt, which we generated earlier by runninggenerate_wallet.py. Using that you can make a valid transaction:
That transaction now can be mined by/mine. For example,http://localhost:5001/mine:
Just like this you can make multiple transactions and mining will put them in a block which will be added to blockchain of each peer.You can view the entire blockchain on/chain view. For example,http://localhost:5000/chain:
Also there are other views like/peers,/consensus,/unconfirmed_transactions, etc.
About
Simple blockchain implementation using python and flask. It implements basic concepts of blockchain, like proof of work, mining, consensus, generating and validating the signature on transaction etc.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.