Giter Site home page Giter Site logo

nbietz / web3-marketplace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daniellemorganlapis/web3-marketplace

0.0 1.0 0.0 623 KB

Consensys Academy Developer Bootcamp Final Project

License: MIT License

HTML 0.48% CSS 0.22% JavaScript 95.58% Solidity 3.72%

web3-marketplace's Introduction

For Consensys Academy Developer Bootcamp 2020

Online Marketplace

Description: Create an online marketplace that operates on the blockchain.

There are a list of stores on a central marketplace where shoppers can purchase goods posted by the store owners.

The central marketplace is managed by a group of administrators. Admins allow store owners to add stores to the marketplace. Store owners can manage their store’s inventory and funds. Shoppers can visit stores and purchase goods that are in stock using cryptocurrency.

User Stories: An administrator opens the web app. The web app reads the address and identifies that the user is an admin, showing them admin only functions, such as managing store owners. An admin adds an address to the list of approved store owners, so if the owner of that address logs into the app, they have access to the store owner functions.

An approved store owner logs into the app. The web app recognizes their address and identifies them as a store owner. They are shown the store owner functions. They can create a new storefront that will be displayed on the marketplace. They can also see the storefronts that they have already created. They can click on a storefront to manage it. They can add/remove products to the storefront or change any of the products’ prices. They can also withdraw any funds that the store has collected from sales.

A shopper logs into the app. The web app does not recognize their address so they are shown the generic shopper application. From the main page they can browse all of the storefronts that have been created in the marketplace. Clicking on a storefront will take them to a product page. They can see a list of products offered by the store, including their price and quantity. Shoppers can purchase a product, which will debit their account and send it to the store. The quantity of the item in the store’s inventory will be reduced by the appropriate amount.

Directories

/client/src/App.js - the front end

/contracts/ - Solidity contracts

/test/marketplace.test.js - 12 tests for marketplace contract and the manageable interface

Used with:

node v12.18.4 (npm v6.14.6)

Truffle v5.1.46

solcjs 0.5.16

ganache-cli v6.10.2 (ganache-core: 2.11.3)

Instructions

Running locally

In the root directory, run:

ganache-cli

A list of accounts and private keys appears. Under the line below "HD Wallet", there is a Mnemonic of 12 words. Create a .secret file in the root directory of the project and copy and paste these 12 words into the .secret file and save.

If you need to cancel ganache-cli and re-run it, start ganache-cli -m, followed by the 12 words in the secret file between "" to start the local chain with those keys.

To deploy the contracts to the local chain that ganache-cli is running, open up a new terminal, then run:

truffle migrate

Run the tests with:

truffle test

To start the react app:

cd client/src
npm start dev

In Metamask, click on the icon in the upper-right, and select to "Import Account". In the terminal ganache-cli is running has a list of private keys, select the private key that is associated with account (0) and import into Metamask, this is the master admin account for the application.

Set up Metamask to connect to Custom RPC, have it connect in the browser to the 127.0.0.1 localhost, port 8545, on the react app tab, localhost:3000.

First account starts with 2 stores, admin and store owner access. There is a limit of 16 stores.

Connecting to rinkeby

Alternatively, you can connect and use the app on the rinkeby network, instead of running locally.

To start the react app:

cd client/src
npm start dev

In the web browser, on the localhost:3000 tab, select the Rinkeby Test Network to interact with the application.

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.