Giter Club home page Giter Club logo

blockchain-in-node's Introduction

blockchain-in-node Build Status

This is an afternoon-project, a blockchain built in node, supporting PoW.

Why Node

Node itself is a more beautiful, flexible and powerful language for internet project, again, I want to show my love to js.

Why a Blockchain from scratch

When it comes to blockchain, most developers only learn how to do Dapp with ethereum, neo, or other existing infrastructure-completed project... They are fine, but using them will only let you know what you can do with them, as a result, you cannot really get the idea what you can do with blockchain itself, and what you can apply the blockchain mindset to other software projects. I think there is a better way to understand blockchain itself - to build a chain from scratch

This is a lovely demo for

  • A general Idea of how Blocks, Chain, Mining, Nodes, Transaction work with each others.
  • How to do them in Node
  • How to resolve basic conflicts in blockchain
  • How to use sha256 to do PoW(Proof of Work)
  • Not a demo for
    • signatures
    • address
    • production setup
    • making you a blockchain expert

Run it on your machine

$ npm clone https://github.com/amazingandyyy/blockchain-in-node.git
$ npm i
$ npm run dev // default on port 3000

<!-- to run more nodes -->
$ npm run nodes // default on port 3000
$ npm run nodes 3000 // listening on port 3000
$ npm run nodes 3001 // listening on port 3001
$ npm run nodes 3002 // listening on port 3002

HTTP Endpoints

GET /blockchain // see the link-list itself
POST /blockchain/mine // find the next special hash
POST /blockchain/body // add new data to the chain 

GET /blockchain/nodes // get a list of all nodes
GET /blockchain/nodes/resolve // fetch the longest chain
POST /blockchain/nodes/register // add nodes urls

There are many can be done:

Please feel free to fork, clone or send me PR

  • use socket instead of http, to broadcast state
  • implement signature, public key, private key, user address system
  • proof of work and rewarding system
  • new PoW algorithm
  • location based sharding?
  • hide IPs / make it private!?
  • PoS, or other dBFT methods
  • dockernized, easy to run a node
  • interactive wrappers, helper libraries(python, golang, java)...

Author

Andy Chen(amazingandyyy)

LICENSE

MIT

JavaScript Style Guide

blockchain-in-node's People

Contributors

amazingandyyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blockchain-in-node's Issues

Questions on Front-End Display

Hello,

I am fairly new to nodejs, so this may be do to my lack of knowledge.

But I am having trouble getting the transactions to display on the localhost:3000.

Steps to reproduce

  1. npm run node

#this connects the server.

  1. Http EndPoints. Do I have to do more coding to access them? Or Can I run this in the terminal with a command?

I run this in the terminal.

POST /blockchain/body // add new data to the chain

Please enter content (application/x-www-form-urlencoded) to be POSTed:
12345896

^C #have to Force Exit

  1. I also tried to run the test file.

npm run test

[email protected] test /home/user/blockchain-in-node
eslint .

Should Andy and Johns Transactions be displayed on the local host after running this command?

let transaction = new Transaction('Andy', 'John', 10);
let nextBlock = blockchain.buildNextBlock([transaction]);
blockchain.addBlock(nextBlock);

let transaction2 = new Transaction('John', 'Andy', 5);

Thank you,

E

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.