Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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.

NotificationsYou must be signed in to change notification settings

Adiprogrammer7/blockchain_implementation

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!

Instructions to run:

First download the repo on your local machine using git clone:

git clone https://github.com/Adiprogrammer7/blockchain_implementation.git

Then navigate to repo and install dependencies:

pip install -r requirements.txt

In 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 --reload

For the second instance on port 5001:

set FLASK_APP=main.pyflask run --port 5001 --debugger --reload

Now we will have two instances running onhttp://localhost:5000 andhttp://localhost:5001.
index

How it works:

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:
image

That transaction now can be mined by/mine. For example,http://localhost:5001/mine:image

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:image

Also there are other views like/peers,/consensus,/unconfirmed_transactions, etc.

Open to any useful contribution :)

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp