KuroGuo / my-little-bitcoin

Simple JavaScript cryptocurrency implementation

Home Page:https://vedmant.com/little-bitcoin-simple-cryptocurrency-implementation-javascript-gui/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

My Little Bitcoin

A simple cryptocurrency implementation on JavaScript in just about 650 lines of code (with comments) for blockchain and 300 for peer to peer connections and web API. It also includes WEB GUI written on Vue.js where you can send coins and explore blockchain.

See Demo Here

Features

  • Blocks mining with reward and simple POW
  • Create transactions and send amount to address using unspent outputs
  • Peer to peer connection, blockchain synchronization
  • Multiple wallets, add new wallet
  • Demo mode mining to reduce CPU load
  • User interface with real time data change
  • Status page with latest blocks, current mempool, wallets list with balances
  • Chain explorer pages for block, address, transaction
  • Descriptive debug messages in develpment mode using debug package
  • Server requests logs with winston

Installation

git clone https://github.com/vedmant/my-little-bitcoin.git # To clone repo
cd my-little-bitcoin
yarn # Install php dependencies
yarn prod # Compile frontend resources

yarn demo # Run in demo mode

And open it on: http://localhost:3001/

Full list of backend run commands

# Start demo node
yarn demo

# Start first node
yarn start

# Start second node
yarn start2

# Start third node
yarn start3

Run 3 nodes with Docker

This will require installed Docker to your PC, run:

docker-compose up

It will build and run all needed containers and run application with exposed ports 3001, 3002, 3003.

Then you can open 3 different nodes that will communicate between each other on: http://localhost:3001 http://localhost:3002 http://localhost:3003

Start mining on one of the nodes to make network add new blocks, you can start mining on each node. Beware, it can consume a lot of CPU resources.

Frontend development

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run prod

# build for production and view the bundle analyzer report
npm run prod --report

TODO

  • Add unit tests
  • Add feature tests
  • Include new transactions in currently mined block
  • Add signature to outputs for transaction, validate signature
  • Implement peers blockhains conflict resolution, download only needed part of chain since split
  • Add stats page with charts in UI, use separate chart module to cache chart data on server
  • Automatic difficulty adjustment to match 1 minute block time

License

And of course:

MIT

About

Simple JavaScript cryptocurrency implementation

https://vedmant.com/little-bitcoin-simple-cryptocurrency-implementation-javascript-gui/

License:MIT License


Languages

Language:JavaScript 71.5%Language:Vue 26.8%Language:CSS 1.3%Language:HTML 0.4%