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
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/
Clone this repository from the terminal by running git clone https://github.com/ankanbag101/blockchain-demo/
cd into the directory to run the program. Run cd blockchain-demo
Run npm install
to install all dependencies.
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
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.
Enter show
in the prompt to show last 10 verified transactions in the blockchain.
Enter tamper
with a block number shown in the show
command.
Example: tamper 2
will tamper with the 2nd verified transaction in the blockchain.
Enter check
to run a validation test that will check the integrity of the blockchain and print a message accordingly.
Enter help
to show the instructions.
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