A Blockchain Example in Typescript
This is a basic example of how the blockchain works. It uses a crypto currency (simpleCoin) as a use case to demonstrate:
- A Transaction
- A Block
- How Blocks are chained
- Proof of Work
- Mining Transactions and Rewards
Limitations:
As already stated this is just a basic example. A fully working and operational blockchain would require much more functionality such as:
- A P2P Network with Transaction Verification
- Blockchain Data Storage to Disk
- Public / Private Keys to secure transactions
- A Wallet
To run this you require the following:
- npm
- Typescript
- gulp
Please see this Typescript Quick Start Guide for some instructions.
Compiling and running
At a terminal prompt browse to your source directory
$ cd blockchain
Compile and build the js file using gulp
$ gulp
This will create a new file in the dist/ folder called blockchain.js.
Run this using node
$ node dist/blockchain.js
This will run the code found in test.ts.
For a full tutorial of how this works please visit my tech blog fullertech.co.uk
Enjoy!