Giter Club home page Giter Club logo

blockchain's Introduction

blockchain

A simple blockchain made in python.

This repository is a barebones implementation of a blockchain. It uses the proof of work protocol (sha256 with 4 leading zeros by default), and uses the 'longest is authoritative' consensus algorithm.

Installation

git clone https://github.com/kasperfred/blockchain.git
cd blockchain

Dependencies

The blockchain relies on requests and Flask.

Usage

This implementation offers a simple webapi for handling nodes.

To start a node, run the following command.

python3 app.py

This exposes a webapi you can use to communicate with the node.

Node Identifier

GET: http://0.0.0.0:5000/

3f99f012-3620-494b-934b-261b6958c511

Register Nodes

This will will add other nodes to the network.

POST: http://0.0.0.0:5000/nodes/register
BODY (JSON): {"nodes":["192.168.1.124:5000", "192.168.1.125:5000"]}

The body should be a JSON object with a nodes key containing a list of reachable addresses belonging to other nodes on the network.

Resolve Conflicts

Runs consensus algorithm (longest chain is authoritative)

GET: http://0.0.0.0:5000/nodes/resolve

Chain

Get the chain of the node.

GET: http://0.0.0.0:5000/chain

Add Transaction

This will add a transaction to a future block.

POST: http://0.0.0.0:5000/transactions/new
BODY (JSON): {"whatever":"your transaction looks like"}

Transaction will be added to Block {block_index}

Mine

This will mine a block using the proof of work protocol.

GET: http://0.0.0.0:5000/mine

blockchain's People

Stargazers

Reza Fatahi avatar

Watchers

Luna Lux Fredenslund avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.