Skip to content

An implementation of a simple blockchain that's distributed across a decentralised p2p network, build with JavaScript.

Notifications You must be signed in to change notification settings

SamuelScotts/fetterchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fetterchain

Table of Contents

Introduction

The main purpose of this application is to provide the ability to hash an image/images, and thereafter add them to a blockchain if they don't already exist there. Should the image already exist on the blockchain, the user is to be alerted and informed.

The blockchain is to be a decentralised network of nodes who each contribute without their identity being compromised. This is to afford uncorrupted cooperation between users.

Technologies

At present, the project ultimately utilises JavaScript. It primarily uses VueJS/Vuetify (for frontend development) and CryptoJS (as its hashing algorithm). Express.js is used as a server for each instance, with the blockchain data being stored there (no data persistance i.e. DB been implemented). Axios is used as the HTTP client for get/post requests.

Tasks:

  • Initialise VueJS Project.
  • Add Vuetify.
  • Add Crypto-JS dependency.
  • Add Express.js.
  • Add Axios.
  • Implement image upload ability.
  • Implement image hasing ability.
  • Add new hash comparision with existing hashes.
  • Implement block addition by user.
  • Allow user to obtain most up to date version of ledger.
  • Distribute additions to ledger appropriately.

To mock the distrubtion/communication of the ledger, a makeshift p2p style network has been implemented using Express servers. These work in a circle, with the server 1 going to server 2, which goes to server 3, who returns to server 1 and so on.

Run the project

Client - move to this directory and use the following command:

npm run serve

Server, Server1, Server2 - move in to each Express server directory (all must be running) and launch using each the following command:

node index.js

Project Images

Basic output after hashing image and adding block containing them:

alt text

Sources

Used the article below for understanding on how to build blockchain using JavaScript: https://medium.com/@spenserhuang/learn-build-a-javascript-blockchain-part-1-ca61c285821e

Used the following StackOverflow answer to assist with file upload and hashing function: https://stackoverflow.com/questions/67159318/file-in-selected-file-array-md5-encryption-with-cryptojs-always-gives-the-same-m

For hashing, using the following project: https://github.com/brix/crypto-js

Issues

One current issue with the project is, by not using a class constructor, the hash of each block will likely result different each time, depending on the order upon which the data is entered in to same. To potentially rebuild block construction with better OOP principles.

About

An implementation of a simple blockchain that's distributed across a decentralised p2p network, build with JavaScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published