Git Product home page Git Product logo

simple_blockchain's Introduction

simple_blockchain

install the requirement package

pip install -r requirements.txt

run the service

node 1

python blockchain.py 5000

node 2

python blockchain.py 5001

endpoint

  • [GET]/blockchain : to check all block on node

  • [POST]/transaction/new : to add new transaction that need to mine format data in json : { "amount": 10, "recipient": "8460674bba154801b5be179b533640a9", "sender": "0" }

  • [GET]/mine : to mine the new transaction

  • [POST]/nodes/add_nodes : to add nodes to another nodes format data in json : { "nodes":[ "http://127.0.0.1:5000" ] }

  • [GET]/nodes/sync : to sync the node or update the node

simulation

  • node 1: add new transaction -> mine -> view the blockchain
  • node 2: view the blockchain
there will be different block between them:
- node 1: 2 blocks
- node 2: 1 block
to sync them:
  • node 1: add node 2 using /nodes/add_nodes

  • node 2: add node 1 using /nodes/add_nodes

  • node 1: sync the node 1 using /nodes/sync

  • node 2: sync the node 2 using /nodes/sync

result:
- node 1: 2 blocks
- node 2: 2 blocks

simple_blockchain's People

Contributors

indraryadi avatar indraappkey avatar

Watchers

 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.