Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Latest commit

 

History

History
82 lines (48 loc) · 4.27 KB

README.md

File metadata and controls

82 lines (48 loc) · 4.27 KB

DERO Marketplace Smart Contract

Built for the Dero Smart Contract build competition

Winner of the 2nd place

Fully functional yet simple marketplace where users can buy and sell goods without the need of a centralized e-commerce platform. Made in DERO-BASIC, running on the DERO-DVM.

⚡ This smart contract was developed back in 2019 for the DERO Stargate RC1 testnet and will not be suitable for the latest release of the platform. A new, more advanced, up to date project to replace this SC will be developed.

Donations

DERO: dERoWuoU8wthSaUCRJN6HuFpfuaQKnPftTfXoBbi7CaLVTFCGdYrPN5iZTWNcqiZkbEVqaGduHt6C2CagHV2SPQd9VU1UknF1N

Schema

Refer to Schema.txt to understand the structures the marketplace is made up on.

Functions

Seller functions

AddProduct(name, description, price, amount) - Adds a new product to the marketplace.

RemoveProduct(product_id) - Removes a product from the marketplace.

ChangeProductAmount(product_id, new_amount) - Changes the amount of a product for sale.

FulfillOrder(order_id) - Confirms a order went through thus sending the funds to the seller.

Buyer functions

BuyProduct(value, product_id, amount) - Buys a product. value should be equal to the product price multiplied by the amount bought. If not, unused coins will be sent back to the buyer address.

ReviewOrder(order_id, satisfied, comment) - Reviews a order. The buyer can either give a positive (satisfied = 1) or a negative (satisfied = 0) opinion. Comment is optional. By reviewing an order, its seller gets a feedback. Total feedback is equal to positive feedback minus negative feedback.

Common functions

CancelOrder(order_id, reason) - Cancels a order. Can be used by either the buyer or the seller. Spent coins will be returned to the buyer. A order can not be canceled if it has already been fulfilled by the seller.

SetContactInfo(contact_info) - Sets the contact info of a user. Said contact info is needed in order for buyers and sellers to communicate shipping addresses/other info. Since data stored on the blockchain is currently public, contact_info should be something anonymous such as a ProtonMail address or a Wickr username.

Frontend

I felt a frontend for this SC was needed in order to display data (products, orders and reviews) in a readable and understandable way to the human eye and to make interactions (buy/sell/etc) easier.

It's not going to be neither the best looking frontend, nor the most well coded but, since the main focus of the competition was to build a functional smart contract anyway, I decided to sacrifice beauty and fancy frameworks for semplicity and lightweighness' sake. I like React/Vue like anyone else but I felt they would've been overkill, so I went along with good ol' plain JavaScript ES8.

How to run

  1. Download the frontend folder from this repository.

  2. Make sure daemon and wallet are running and synced.

  3. Open your web browser with web security disabled. This is needed in order to bypass a CORS issue with the daemon's JSON RPC server (thanks to plspro for providing this quick fix). Example (Chrome on Ubuntu):

    $ google-chrome --disable-web-security --user-data-dir=/path/to/data/dir

  4. Open index.html with your browser.

Tested on the latest version of Chrome and Firefox. If you're using a older browser and running into compatibility issues, you may need to pass the js file through BabelJS and the css file through a prefixer.

Frontend Screenshots

Connection

Connection

Market

Market

Buyer Orders

Buyer Orders

Set Contact Info

Set Contact Info

Add Product

Add Product

Seller Products

Seller Products

Seller Orders

Seller Orders