My Little Bitcoin – simple cryptocurrency implementation on JavaScript with GUI

I was interested in Bitcoin and Blockchain technologies for a while and in theory things look pretty simple yet so powerful. I really admire genius of Satoshi Nakamoto or whoever invented Blockchain based Crypto Currency and eventually I decided to implement my own simple cryptocurrency to study it better, as for me the best way to learn is to do it myself.

And the result is My Little Bitcoin – a simple cryptocurrency implementation on JavaScript in just about 650 lines of code (without comments and client). It also includes WEB GUI written on Vue.js where you can send coins and explore blockchain.

The structure

The project is based on Node.js and has following basic structure:

  1. Library – consist of functions to help handle crypto currency in a simplest way
  2. Store – this in-memory storage for blockchain, wallets, mempool and few other things
  3. Miner – this a worker that adds new blocks to the chain
  4. Peers – simple peer-to-peer blockchain synchronization implementation
  5. Server – web server that serves data for our front end GUI, includes API and web sockets

The chain

The structure of the chain is the simplest possible.

Block structure is following:

{
  index, // Block index
  prevHash, // Hash of the previous block
  time, // Current block timestamp
  transactions, // List of transactions, included into the block
  nonce, // Nonce, required for proof of work protocol
  hash, // Current block hash
}

Transaction structure is following:

{
  id, // Transaction unique id
  time, // Transaction timestamp
  hash, // Transaction hash
  reward, // Boolean to mark mining reward transaction
  inputs, // List of inputs in the transaction
  outputs, // List of outputs in transaction
  address, // Transaction is limited to only one input address for simplicity
  hash, // Transaction hash
  signature, // Transaction hash signature
}

And following inputs and outputs structure:

// Input
{
  tx, // Points to transaction of referenced output
  index, // Index of the output in the referenced transaction
  amount, // Amount of the referenced output
  address, // Address of the referenced output and also public key
  signature, // Signature, signed by private key and can be verified by included public key
}
// Output
{
  index, // Output index in current transaction
  amount, // Amount of the output
  address, // Address of the wallet (public key)
}

For demo purpose I created special mode that disables peer-to-peer module, reduces proof of work difficulty and adds one minute block timeout.

Demo

Check sources here: GitHub Link

This implementation is pretty naive and suitable only for studying purpose.

This project is fully free to use for any purpose and licensed under MIT License.

Sample Single Page Application (SPA) using Laravel 5 & Vue2 + Vuex + Vue-Router

Not to long ago I implemented a sample Single Page Application using Laravel 5 and Vue2 + Vuex + Vue-Router.

Today I decided to make it public and share my experience with others.

The project is basically a simple Running Tracker, where you can add your running entries and see your performance during some period of time.

Main features

  • Fully separate Backend and Frontend
  • Authentication based on Laravel Passport
  • List pages with filters and CRUD editing
  • Admin panel
  • Simple widgets
  • Simple reports
  • Full Phpunit test coverage
  • Sample E2E tests using Nightwatch and Cypress

Includes

Other Features

  • Front page
  • Authentication (registration, login, logout, throttle)
  • Users roles: administrator (all access), manager (manage records)
  • User dashborad with widgets and charts
  • Entries list with filter by date (list, show, edit, delete, create)
  • Report page with chart
  • User profile page
  • Admin dashboard with widgets
  • Users admin (list, show, edit, delete, create)
  • Entries admin (list, show, edit, delete, create)
  • Global loader for all requests with small delay

GitHub Link

Demo

Use login: [email protected] and password: 123456

This project is fully free to use for any purpose and licenced under MIT License.