Skip to content

hasselalcala/blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain (without Proof of Work)

Basically, a blockchain is a decentralized immutable ledger represented by a collection of blocks. Each block can store any type of data, such as information about financial transactions, voting results, medical records, and so on. Each block is linked to the previous one by storing the hash value of the previous block in the chain.

A block in a blockchain is represented by a hash value, and it is very important that cyber criminals can not replace one block with another by preparing fraudulent content that produces the same hash as the legitimate block.

You can think of a block as a record in a ledger. Each block in a blockchain contains app-specific data, and it also has a timestamp, its own hash value, and the hash value of the previous block. In a very simple (and easy to hack) blockchain, an app could perform the following actions to add a new block to the chain:

  1. Find the hash of the most recently inserted block, and store it as a reference to the previous block.
  2. Generate a hash value for the newly created block.
  3. Submit the new block to the blockchain for validation.

At some point the blockchain was created, and the very first block was inserted into this chain. The very first block in a chain is called a genesis block. There are no blocks before this first one, so the previous block’s hash doesn’t exist.

About the project

I create a blockchain without proof of work and add blocks to it. Previous to add a block to the chain, is necessary to calculate the SHA-256 hash for the new block, and store a reference to the hash of the previous block. Also add a index, timestamp, and somedata to the block.

This program run from the command line using node.js and the crypto module to generate SHA-256.

Reference.

This project is based on "Typescript quickly" (Yakon Fain and Anton Moiseev).

About

A basic blockchain without proof of work

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published