Giter Site home page Giter Site logo

lotto-blockchain-example's Introduction

Blockchain Lottery

This is a proof of concept repository for a simple blockchain lottery that I created for a blog post I wrote www.twistedbrackets.com/decentralised-lottery-with-blockchain/. The lottery is designed to have a single draw and limited functionality, focusing on the creation and validation of entries in the blockchain.

Scope

To manage the scope for this proof of concept, we have defined some parameters we will work within:

  • We will focus on a single lottery draw.
  • We want to limit the ability to add entries to the blockchain to only authorised nodes but still allow the chain to propagate to other nodes for validation.
  • We want to ensure that the valid owner of an entry can be proven.
  • We will only focus on the initial purchase status, not allowing entries to be cancelled or prizes claimed.
  • We will not add any complicated mechanics to manage race conditions across the network, simply rejecting a block if this edge case does eventuate.
  • We will store our blockchain in a simple JSON object to be easily serialisable and only maintain it in memory.
  • We will create a simple API to add view and validate ownership of enteries in our lottery.

We will tackle this in two parts:

  • Create the classes to manage the blockchain data structure.
  • Create a NodeJs express server to act as our blockchain nodes and manage block addition, validation and propagation. The server will use sockets to communicate with each other and a simple REST API to contribute to the chain. The socket connection in the proof of concept will be kept simple, not allowing for loss of connection and reconnection to the network.

Usage

The script uses the Commander library to parse command-line arguments. The available options are:

-p, --port : The port to run the BlockchainNode on. If not specified, the default value is 3000.

-h, --host : The hostname or IP address of the node to connect to.

-v, --verbose : Display detailed processing information. If not specified, the default value is false.

-k, --key : Private key used to validate a new block added to the blockchain.

-s, --save : Save the private key to file.

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.