Git Product home page Git Product logo

simplechain's Introduction

✨⛓ Simplechain ⛓✨

CircleCI Status Coverage Status

Interactive blockchain built with Node.js.

demo

Intro

The blockchain is a fascinating technology, but it can also be intimidating. At the time I wrote this code, I had consumed a lot of material regarding the blockchain and cryptocurrencies, but I hadn't satisfied my hunger for knowledge (and still haven't). I wanted to create my own blockchain for some of that knowledge to sink in, and I wanted it to be simple. Simplechain is the result of that, and I hope you find it as helpful as it was for me when I created it.

Check out Simplechain++ for a C++ port.

Usage

First, clone the repo:

$ git clone https://github.com/olistic/simplechain.git
$ cd simplechain

Then, install the dependencies:

$ npm install

And finally, launch the REPL:

$ npm start

Voilà! If you see the SIMPLECHAIN> prompt, it means you're inside the REPL.

Go ahead and try the following commands:

  • ADDBLOCK <data>: Mines a block with the provided data and adds it to the chain.
  • LISTBLOCKS: Lists all the blocks in the chain.

Well done! If you want to learn more, please don't forget to look at the code.

Advanced Usage

Adjust Difficulty

If you want to tweak the blockchain's difficulty, you can do so via the CLI:

$ npm start -- --difficulty <number>

This number represents the amount of zeros the hashes of the blocks in the blockchain need to begin with. A greater number makes it more difficult (more computationally expensive) to mine a block.

Next Steps

  • Implement P2P network of nodes where:
    • Miner nodes broadcast mined blocks
    • User nodes broadcast data to be included in blocks by miners
  • Implement peer discovery protocol so nodes can find each other

Resources

License

MIT

simplechain's People

Contributors

olistic avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simplechain's Issues

Optimize Block (and Blockchain) validations

When validating a block, the hash of the provided previous block is being unnecessarily recalculated. The impact of this is greater in the validation of the entire blockchain, where each block is validated and its hash calculated twice (once when validating the block itself and another time when validating the next block).

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.