- clone the repository to local directory
- go to blockchain-based-trading folder
- npm install This will download all the dependencies
Please note that all the mentioned steps are required
-
Start an ethereum (geth) node OR a quorum node and type geth attach
- In geth console window, Launch scripts using command loadscript("") :
- 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)
- 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.
-
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
-
Update retailers.json :
- 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)
-
MongoDB products
- Setup mongodb server and create a database named "loyaltyRewards"
- copy products.json from setup folder and use mongoimport to fill products collection mongoimport -d loyaltyRewards -c products --file products.json
-
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
command : node server.js
You can access the application at localhost:3000
Register a user using GUI, this process in the backend will do 2 things :
- Create a new user in local database
- Create an ethereum account for this user (This account password will be the password used to register) (DEMO PURPOSES)
- Select a random account from retailers.json, which will transfer some initial tokens from retailer account to user account. (DEMO PURPOSES)
Login using your username and password
Now, this will open the shopping/transfer website for you where you can :
- Buy a product using your loyality points
- Transfer your loyality points to any other user using his public key
- View your passbook
Refer to screenshots folder for system look!