Giter VIP home page Giter VIP logo

blockchain-based-trading's Introduction

Loyalty rewards on blockchain

Setup

  1. clone the repository to local directory
  2. go to blockchain-based-trading folder
  3. npm install This will download all the dependencies

Pre-requisites before starting server

Please note that all the mentioned steps are required

  1. Start an ethereum (geth) node OR a quorum node and type geth attach

    1. In geth console window, Launch scripts using command loadscript("") :
    2. createRetailAccounts.js : This script will create 10 retail organisation accounts, unlock them, and transfer ethers to these accounts for transactions, Your coinbase should already have some ethers for this puropse (Required for demo purposes)
    3. tokenDeploy.js : This script will deploy loyality tokens contract on the peer to peer network. Allot initial tokens to the genesis (caller) address. This script also returns the contract address.
  2. Update config.json : 1.tokenAddress : Copy the address returned by tokenDeploy.js in this field 2. nodeAddress : Enter node rpc address to which application will connect

  3. Update retailers.json :

    1. Add created addresses from createRetailAccounts.js to this json file and keep password as "retailers" //you can change it as per your address password (Required for demo purposes)
  4. MongoDB products

    1. Setup mongodb server and create a database named "loyaltyRewards"
    2. copy products.json from setup folder and use mongoimport to fill products collection mongoimport -d loyaltyRewards -c products --file products.json
  5. Final Step is to add list of created retail addresses as genesis addresses in token contract (Allows them ownership in loyality points) using setGenesisAddressArray function of contract which accepts an array of addreses to make them owner. This function can only be called via an already owner. If not using console, you can you one of the server API to do this : POST : localhost:3000/api/transaction/genesis Parameters example:

{
	"address": "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
	"password": "retailers",
	"genesisAddresses": "0x00ebace8aa25281d8ab4e30082759077384e264d;0xbec2822622448995975c9c649c17d597b1073627;0x8f51274a2d362345c9a9ee54c84ab15cc78d3450"
}

Remember to seperate addresses by ";"

After all the steps are completed

start the server

command : node server.js

You can access the application at localhost:3000

Process information

Registering a user :

Register a user using GUI, this process in the backend will do 2 things :

  1. Create a new user in local database
  2. Create an ethereum account for this user (This account password will be the password used to register) (DEMO PURPOSES)
  3. Select a random account from retailers.json, which will transfer some initial tokens from retailer account to user account. (DEMO PURPOSES)

Login User:

Login using your username and password

Now, this will open the shopping/transfer website for you where you can :

landing page

  1. Buy a product using your loyality points
  2. Transfer your loyality points to any other user using his public key
  3. View your passbook

Refer to screenshots folder for system look!

blockchain-based-trading's People

Contributors

sakaarbhatia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.