Git Product home page Git Product logo

bchain's Introduction

bchain

A very basic implementation of a blockchain - builted for educational purposes -.

Usages:

To interact with your blockchain, first you need to run the server. On command prompt, enter your project's current folder and type: $ python runserver.py

  • Serving Flask app "blockchain_api" (lazy loading)
  • Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

With your server up and running, to mine a block you need to make a GET request to http://localhost:/mine.

To create a new transaction and append it to the next block to be forged, make a POST request to http://localhost:/transactions/new - with the body of the post containing a JSON like the example below:

{ "sender": "m4ee26xbc15148ee92c6cd394edd974a", "recipient": "someones-address", "amount": 3 }

After creating new transactions and mining a new block, you can evaluate the current state of your entire chain by making a GET request to http://localhost:/chain.

To add new network neighbouring nodes to your list of nodes your can simply run the server on another port (runserver.py will look for an available port automatically) and make a POST request to http://localhost:/nodes/register - with the body of the request containing a json like the example below:

{ "nodes": ["http://127.0.0.1:"] }

After that, you can mine new blocks on your added node and verify its authoritativeness by making a GET request to http://localhost:/nodes/resolve - which will resolve the current state of the chain by replacing it if a valid chain is found, whose length is greaters than ours.

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.