• Stars
    star
    819
  • Rank 55,659 (Top 2 %)
  • Language
    Python
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fully functional blockchain application implemented in Python from scratch (with tutorial).

python_blockchain_app

A simple tutorial for developing a blockchain application from scratch in Python.

What is blockchain? How it is implemented? And how it works?

Please read the step-by-step implementation tutorial to get your answers :)

Instructions to run

Clone the project,

$ git clone https://github.com/satwikkansal/python_blockchain_app.git

Install the dependencies,

$ cd python_blockchain_app
$ pip install -r requirements.txt

Start a blockchain node server,

$ export FLASK_APP=node_server.py
$ flask run --port 8000

For windows users

set LANG=C.UTF-8
set FLASK_APP=node_server.py
flask run --port 8000

One instance of our blockchain node is now up and running at port 8000.

Run the application on a different terminal session,

$ python run_app.py

For windows users

set LANG=C.UTF-8
set FLASK_APP=run_app.py
flask run --port 8000

The application should be up and running at http://localhost:5000.

Here are a few screenshots

  1. Posting some content

image.png

  1. Requesting the node to mine

image.png

  1. Resyncing with the chain for updated data

image.png

To play around by spinning off multiple custom nodes, use the register_with/ endpoint to register a new node.

Here's a sample scenario that you might wanna try,

# Make sure you set the FLASK_APP environment variable to node_server.py before running these nodes
# already running
$ flask run --port 8000 &
# spinning up new nodes
$ flask run --port 8001 &
$ flask run --port 8002 &

You can use the following cURL requests to register the nodes at port 8001 and 8002 with the already running 8000.

curl -X POST \
  http://127.0.0.1:8001/register_with \
  -H 'Content-Type: application/json' \
  -d '{"node_address": "http://127.0.0.1:8000"}'
curl -X POST \
  http://127.0.0.1:8002/register_with \
  -H 'Content-Type: application/json' \
  -d '{"node_address": "http://127.0.0.1:8000"}'

This will make the node at port 8000 aware of the nodes at port 8001 and 8002, and make the newer nodes sync the chain with the node 8000, so that they are able to actively participate in the mining process post registration.

To update the node with which the frontend application syncs (default is localhost port 8000), change CONNECTED_NODE_ADDRESS field in the views.py file.

Once you do all this, you can run the application, create transactions (post messages via the web inteface), and once you mine the transactions, all the nodes in the network will update the chain. The chain of the nodes can also be inspected by inovking /chain endpoint using cURL.

$ curl -X GET http://localhost:8001/chain
$ curl -X GET http://localhost:8002/chain

More Repositories

1

wtfpython

What the f*ck Python? 😱
Python
35,526
star
2

readme_styles

Minimal README.rst and README.md template for Github projects.
65
star
3

tor-hidden-service-python

A very basic project creating a `.onion` website for Tor using Flask framework and python.
HTML
31
star
4

q-learning-taxi-v3

Simple q-learning implementation for taxi-v3 environment of Open AI gym.
Python
20
star
5

python-keylogger

A simple keylogger made in python
Python
17
star
6

deblurring_cnn

CNN implementation in Tensorflow for Deblurring text images
Python
16
star
7

shopify-data-generator

A data generator script for Shopify
Python
14
star
8

smart_power

Decentralized electricity distribution system [Hackathon project]
Python
9
star
9

snakepy

Classic snake game implemented using pygame and Reinforcement learning
Python
8
star
10

ibm_iot_example

Door Montioring System built with Python and IBM Cloud. Covers IoT architecture, device management, analytics and security
Python
7
star
11

python_automated_pipeline

Automating Python development workflow [with tutorial]
Python
7
star
12

wolframalpha-python-wrapper

A python wrapper for search api of WolframAlpha
Python
6
star
13

blockchain_primer

Exhaustive explanation and Python implementation of blockchain
5
star
14

python-redis-queue-example

A simple setup illustrating redis-queue based background task processing in Python. Supports heroku.
Python
5
star
15

smartcab

A self driving car simulation in python
Python
4
star
16

witty

E-commerce with a difference
Java
4
star
17

horaFeliz

Next Generation E-retail management (Hackathon project)
CSS
3
star
18

face-dj

A fun hackathon project attempting to create a basic DJ using facial expressions.
TypeScript
3
star
19

xarvis

A python based voice assistant and clipboard utility
Python
3
star
20

oss_first_contribution

A repository to get beginners started with Open Source!
3
star
21

parking_lot_prototype_python

Simple parking lot implementation in Python. Implemented as a submission for gojek.
Python
3
star
22

comprehensive_image_search

Script for scraping/fetching images/gifs from Bing, Google and Giphy for a particular topic.
Python
2
star
23

subtitles_to_plaintext

Convert .srt file to plaintext files
Python
2
star
24

tweet_scraper

A CLI based scraper script for Twitter. Supports languages, search query, and sentiments.
Python
2
star
25

pi-nodered-homekit-automation

Example implementation of a smart doorbell system using Node RED, and Apple HomeKit
2
star
26

Library-Automation-Tool

Automation tool in python to Manage Library account at Delhi Technological University
TeX
2
star
27

OneClickDTU

Informational Website for Delhi Technological University
Python
1
star
28

visionAR

A Google lens like Unity app with a translator (built as an overnight hackathon project)
C#
1
star
29

netzero-backend

Solidity
1
star
30

youtube_hook

Automatic offline videos syncing tool for Youtube channels and playlists.
OpenEdge ABL
1
star
31

3toN-backend

Permissionless video streaming platform with real-time streaming payments.
JavaScript
1
star