Skip to content

Quartz is a decentralized cash system built like a blockchain, but which stores user data on a webTRC-based graph database to allow for faster queries and light-weight storage.

Notifications You must be signed in to change notification settings

evadegano/quartz

Repository files navigation

Quartz

Quartz is a decentralized cash system built like a blockchain, but which stores user data on a webTRC-based graph database to allow for faster queries and light-weight storage.

The app is available here

Table of contents

Scope

The app was built as a second project during Ironhack's Full Stack Developer bootcamp. It was awarded gold medal for best project by teachers and students.

Features

  • User authentication and authorization via Passport
  • Password reset via Nodemailer

  • Off-chain data stored in a MongoDB database
  • On-chain data stored on Gun

  • Purchasing QRTZ Coins via Stripe

  • Proof of Work algorithm for block mining
  • Merkle Tree structure for storing transaction data

Development

Setup

Requirements

Config variables

Add the following variable with your own values inside a .env file:

Server-side

  • PORT=5005 (local port to call the server)
  • ORIGIN=http://localhost:3000 (local URL to call the app)
  • MONGODB_URI=mongodb://localhost/quartz (local URL to call the database)
  • GMAIL_USER (Gmail address for Nodemailer)
  • GMAIL_PWD (Gmail address password)
  • STRIPE_PRIV_KEY (private key from your Stripe developer account)

Client-side

Install

# install dependencies
$ npm i 

Run

# launch the app in development modeh
$ npm run dev

Populate with dummy data

Server-side

Populate the MongoDB dabatabase with dummy users and wallets with the functions in ./bin/seed.js.

Client-side

Populate the GunJS decentralized database with a dummy blockchain and transactions with the functions in ./client/src/bin/seed.

  1. Replace the content of wallets.json with the dummy wallets you have generated on the server-side.

  2. Go to the /seed route.

Click on the following buttons:

  • Init blockchain instance: creates an instance of the singleton blockchain class in GunJS.
  • Top up wallets: generate random transactions to top wallets up and store them on GunJS.
  • Verify pending transactions & mine block: select a random wallet to verify current pending transactions and mine them into a block.
  • Generate random transactions: generate random transactions between wallets and store them on GunJS.

Check your console for success or failure messages.

Deploy

You must log into Heroku first.

# create an Heroku app in the root directory
$ heroku create -a example-app
# deploy to Heroku
$ git push heroku main

API

POST /signup

Create a new user.

POST /signup
{
  "email": "jdoe@gmail.com",
  "password": "Foobar@01",
  "passwordConfirm": "Foobar@01"
}

Response:

{
  "newUser": {
    "_id": "620d2a6cd7ba8f53a70a75e1",
    "createdAt": "2022-02-16T16:46:36.854+00:00",
    "email": "jdoe@gmail.com"
  }
}

POST /login

Log a user in.

POST /login
{
  "email": "jdoe@gmail.com",
  "password": "Foobar@01"
}

Response:

{
  "userData": {
    "_id": "620d2a6cd7ba8f53a70a75e1",
    "createdAt": "2022-02-16T16:46:36.854+00:00",
    "email": "jdoe@gmail.com"
  },
  "walletAddress": "4cd203f4eb2534875ac1fb365792ad020f87a2fda9633bfd062074ae2e82f9b1"
}

GET /loggedin

Check whether a user is logged in.

Response:

{
  "userData": {
    "_id": "620d2a6cd7ba8f53a70a75e1",
    "createdAt": "2022-02-16T16:46:36.854+00:00",
    "email": "jdoe@gmail.com"
  },
  "walletAddress": "4cd203f4eb2534875ac1fb365792ad020f87a2fda9633bfd062074ae2e82f9b1"
}

Error: 403

{
  "message": "Unauthorized"
}

PUT /:userId

Update a user's account data.

PUT /:userId
{
  "email": "jdoe@gmail.com",
  "password": "Foobar@01",
  "passwordConfirm": "Foobar@01"
}

Response:

{
  "user": {
    "_id": "620d2a6cd7ba8f53a70a75e1",
    "createdAt": "2022-02-16T16:46:36.854+00:00",
    "email": "jdoe@gmail.com"
  }
}

DELETE /:userId

Delete a user's account.

Response:

{
  "message": "Your account has been removed successfully." 
}

POST /wallets

Create a new user wallet.

POST /wallets
{
  "userId": "hfu178387bde190332",
}

Response:

{
  "walletAddress": "4cd203f4eb2534875ac1fb365792ad020f87a2fda9633bfd062074ae2e82f9b1"
}

POST /coins

Add QRTZ Coins to a user's wallet.

POST /coins
{
  "amount": "3000",
  "token": "",
  "keypair": "",
  "publicKey": ""
}

Response:

{
  "amount": "3000",
  "keypair": ""
}

Sources

This project is based on O'Reilly's Mastering Bitcoin.

Available at: https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/

About

Quartz is a decentralized cash system built like a blockchain, but which stores user data on a webTRC-based graph database to allow for faster queries and light-weight storage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published