Skip to content

tocausan/naive-chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Naive Chain

Waffle.io

Description

Basic blockchain nodejs implementation. this project follows Lauri Hartikka's article: "A blockchain in 200 lines of code"

Principle

A device contains a database which contains all the chain, a public and a private key. A block contains a content which is hashed by its creator and the hash of the previous block it depends on.

Once the block created it will be sent over the network for validation from other devices. If confirmed, this block is then stored in the database. A block is immutable, it can be read but can't be modified or deleted.

The device is able to read blocks only created by itself.

Encryption

The encryption used is AES192 due to it's speed, lightweight and safety.

Models

Block
  • index : number
  • timestamp : any
  • data : number
  • nonce : string
  • prevHash : string
  • currHash : string
  • qrCode : string
Database

Collections:

  • blocks

API

GET     /api                    API infos
GET     /api/block/all          get all blocks
POST    /api/block/one          get one block
GET     /api/block/create       create one block
GET     /chain/check            check chain integrity

Setup

# clone the repo
git clone [repo] [name?]
cd [naive-chain | name?]

# build server
npm run build

# start mongodb services
brew services start mongodb #osX

npm [start | run dev]

Client infos

About

Blockchain implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published