---
# System prepended metadata

title: Decentralised Marketplace Tech Spec

---

# Decentralised Marketplace Tech Spec

## Escrow Smart Contract

Features of this escrow contract

- Create new trade with following fields
    - seller address
    - buyer address
    - name of physical good
    - address of ERC20 token for accepting payment
    - amount of physical good in a physical unit
    - amount of ERC20 token being paid for trade
    - amount of ERC20 token required as security deposit from seller
    - amount of ERC20 token that will be deducted if buyer defaults

- Sponsor this trade
    - Ask seller to deposit 1% of required amount of ERC20 or a fixed amount as security deposit
    - After seller deposits, ask buyer to deposit required amount of ERC20

- Dispatch physical good
    - Updates state of contract to non cancellable. Before this it was cancellable without with full refund
    - Update amunt of token paid for delivery

- Accept or reject physical good
    - When goods arrive at buyer physical address they can check the quality and then buyer has to either accept the good or reject it. Because this decision needs to be taken on the spot at the time of delivery we need to limit scope this solution to good that are variable at the time of delivery
    - Accept physical good
        - buyer's deposit is transferred to selller address
        - seller's deposit is returned to it
    - Reject physical good
        - We can either transfer seller deposit and part of buyer's deposit to a decentralised court or a centralised court for dispute resolution
        - Or we can simply assume seller to default and keep his deposit as platform payment and return buyer his diposit. There multiple issues with this assumption based action that are discussed below

### Issues with assumption in case of buyer reject

- A rival seller can bankcrupt another seller by opening trades and rejecting then for no reason as buyer does not lose anything on rejecting
- Buyer can reject the trade just because he found some other offer at better price, again rival seller can take advantage of this system
- Seller has to brea double loss 1. deposit 2. delivery and return transport cost

We see that we need to disintencivise buyer to reject a trade for no reason. We can ask buyer to pay for delivery and return cost if he rejects the good for any reason. But in this case buyer can abose the system and earn money by transporting bad quality good bank and forth to every buyer. 

So catch here is that the buyer's actually loses money if we keep seller security deposit higher than transport cost. But for this we need to know shipping cost before creating trade. I think that's feasible.

So this way platform is earning when buyer rejects the goods on delivery. How do we make sure that platform owner does not start listing good for sell and make free money?

Playform owner can't take redeem this money, it's always locked in the contract it self and used to pay for gas for onchain transactions of buyer's and sellers.

Now if there are not rejections then platfowm owner needs to put money in contract to pay for gas for onchain transaction. How does platform owner make money atleast as much he is investing?

Platform owner can offer auxilarry services around this platform like indexing of good on offer for a fee from seller. Price comparision service for a fee from buyer.

This document is still work in progress. I will keep updating it with update marks when we find out other issues or better solution discussed issues.