Giter Site home page Giter Site logo

harshrajsinh96 / baby_blockchain Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 4.29 MB

Created a Blockchain using Python to allow baby product management while ensuring secure data transmission. Implemented replication with consensus and designed the back-end of Merkle tree to attain an efficient manner. Coded the data storing technique in a way like without database one can record the chain by keeping at least one node always on.

JavaScript 2.54% CSS 60.98% HTML 25.16% Python 11.32%
python3 blockchain proof-of-work replication concensus merkle-tree no-database flask

baby_blockchain's Introduction

Baby_Blockchain

Blockchain for Baby Product Inventory

Technology used

-> Flask
-> Python3
-> Merkle Trees (tools)
-> HTML/CSS/Javascript/Bootstrap
-> Consensus algorithm
-> Replication
-> Proof of Work

How to run

Start nodes

FLASK_APP=server.py flask run --port=5001
FLASK_APP=server.py flask run --port=5002

Register nodes

Include all other nodes in the JSON file other than the node you're already on. Uses proof of work and forges a new block. For registering node 5002 on node 5001:

curl -i -X POST http://localhost:5001/nodes/register -d @register-node5001.json --header "Content-Type: application/json"

For registering node 5001 on node 5002:

curl -i -X POST http://localhost:5002/nodes/register -d @register-node5002.json --header "Content-Type: application/json"

Register a new item as a manufacturer node

curl -i -X POST http://localhost:5001/register -d @entry.json --header "Content-Type: application/json"

{
	"upc": "123",
	"product":"MEGNYA Leather Baby Moccasins",
	"link": "https://www.amazon.com/MEGNYA-Leather-Moccasins-Toddler-ZH0003-Brown-12-5/dp/B07BBVPSPW/ref=sr_1_1_sspa?ie=UTF8&qid=1525936891&sr=8-1-spons&keywords=baby+shoes&psc=1",
	"quantity": "90",
	"price":"18.99",
	"manufacturer": "MEGNYA"
}

Replicate/update nodes

To replicate all new changes (such as the ones made on 5001) on node 5002:

curl -i -X GET http://127.0.0.1:5002/nodes/resolve

To replicate all new changes (such as the ones made on 5002) on node 5001:

curl -i -X GET http://127.0.0.1:5001/nodes/resolve

Run on all nodes that have not been updated.

Transfer ownership of a product : UPDATE THIS JSON

Checks to see that the original owner actually has the product or not. Also checks to see if a product exists with that ID.

curl -i -X GET http://127.0.0.1:5001/transfer

{
	"upc": 123123,
	"old_owner": "Aditi", 
	"new_owner": "Femi"
}

Get the updated blockchain to see updates

curl -i -X GET http://127.0.0.1:5001/chain

Get a specific transaction with transaction ID (returns block that contains the transaction)

curl -i -X GET http://127.0.0.1:5001/transaction/<transaction_ID>

Get a specific product with product ID (returns block that contains the product)

Returns an error statement if a product with that ID does not exist.

curl -i -X GET http://127.0.0.1:5001/product/<product_ID>

baby_blockchain's People

Contributors

harshrajsinh96 avatar

Watchers

 avatar

Forkers

osvapp

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.