Giter Club home page Giter Club logo

blockchain-js-demo's Introduction

Blockchain Javascript Demo

The simplest blockchain client possible, written in Javascript. It should stand by itself, but for more information see my intro to the blockchain here.

Does it work?

Yes. You can create a blockchain, add blocks to it, and accept valid blocks from peer blockchains. However, many 'core' features of the blockchain have not been implemented for simplicity's sake. On the practical side, there is no P2P implementation at all: to send your blocks to others, you need to copy the serialized chain and (e.g.) email it to your peers, who can then paste it into the text field of their own blockchain client. On the theoretical side, many helpful features of the block header have been omitted: indexes, timestamps, and a hash of the block content. The consensus algorithm is also just "longest valid chain wins" - i.e. there is no proof of work or proof of stake.

What's the point?

To help people understand what a blockchain is, with an absolute minimum of distractions. You shouldn't have to wrap your head around the networking or proof-of-work implementation in order to get the core concept.

Isn't a blockchain without proof-of-work just a linked list?

No, it isn't. At the very least it's a hash list or a Merkle list, which is much more interesting than a linked list because it prevents undetectable tampering with history. I think that this no-tampering feature, combined with the "longest valid chain wins" strategy, is enough to make this a (simplest possible) blockchain.

Why don't you include (indexes|timestamps|nonces)?

Because you don't strictly need them to implement the core concept of a blockchain. Indexes and timestamps help preserve the ordering of the blocks in the chain, but the ordering is already determined by the fact that each block contains the hash of the previous block. Other than that, indexes/timestamps can help when there are blocks floating around the P2P network, but since there's no P2P network in this implementation we don't need them here. As for nonces, see above for why I didn't include proof of work.

Other implementations

For a more fleshed-out javascript one, see Naivechain. For a Haskell one, see Legion. Both implement some kind of P2P communication and include indexes/timestamps in their blocks, but neither includes proof-of-work or proof-of-stake. I couldn't find any really good simple examples of that.

blockchain-js-demo's People

Stargazers

Mayank Anand avatar Maheen Mansoor avatar  avatar Max Vasiliev avatar narch avatar Antony Jones avatar Chris McCormick avatar Srijan Shukla avatar

Watchers

James Cloos avatar  avatar

Forkers

arno01

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.