Coder Social home page Coder Social logo

blockchain-demo's Introduction

A simple implementation of Blockchain🔥

This is a bare minimum implementation of the blockchain technology using TypeScript for educational purposes only.

configure the function inside the index.ts to configure the blockchain instance.

This repository is part of a tutorial in Medium

Blockchain illustration

Getting Started

1. Install Node.js:

You need to have npm installed in your computer. It comes with Node.js and you can get it by installing Node from https://nodejs.org/en/

2. Clone Repository:

Clone this repository from the terminal by running git clone https://github.com/ankanbag101/blockchain-demo/

3. Open the Directory:

cd into the directory to run the program. Run cd blockchain-demo

4. Install Dependencies:

Run npm install to install all dependencies.

5. Run the program

Run npm start and the program will start executing with a usage instructions.

git clone https://github.com/ankanbag101/blockchain-demo/
cd blockchain-demo
npm install
npm start

Usage

1. To add a block to the blockchain:

Enter add sender_name receiver_name transfer_amout in the prompt.
Example: add Bob Alice 200 - will create create a block with the transaction of amount 200 sent by Bob to Alice.

2. To show all the transactions in the blockchain

Enter show in the prompt to show last 10 verified transactions in the blockchain.

3. To tamper with a transaction

Enter tamper with a block number shown in the show command.
Example: tamper 2 will tamper with the 2nd verified transaction in the blockchain.

4. To check if the blockchain is valid or not

Enter check to run a validation test that will check the integrity of the blockchain and print a message accordingly.

5. To show the usage instruction on the screen

Enter help to show the instructions.

6. To terminate the program

Enter exit in the prompt or hit ctrl+c

Usage:
-> add sender_name receiver_name transfer_amount  # adds a block to blockchain with the given data
-> show                                           # shows the list of blocks available in the blockchain
-> tamper block_number                            # tampers with the block giver by the number
-> check                                          # validates the blockchain
-> help                                           # show this message
-> exit                                           # close the program

blockchain-demo's People

Contributors

akbng avatar

Stargazers

 avatar

Watchers

 avatar

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.