gumdropsteve / Harmonia

Help your peers agree.
https://hack.ethglobal.co/showcase/harmonia-recthDN1JwwOGYs7r
MIT License
1 stars 0 forks source link
blockchain ethereum smart-contracts

Harmonia

Help your peers agree.

Description

Harmonia is a platform for cost effective, scalable, decentralized dispute resolution through NuCypher time encrypted voting, IPFS file storage, and the SKALE blockchain network. Harmonia is peer to peer dispute resolution.

Video

https://youtu.be/4-_B3PqTTvE

Motivation

Every time I have heard about an AirBnb dispute from a guest, it was the worst thing ever. Every time I have heard about an AirBnb dispute from a host, no complaints. What is the commonality? Neither actually knows how AirBnb handles disputes.

From a business perspective, the cost of losing a random non-host user is probably less than the cost of losing a random host user. This can be derived by comparing the company's $200 reward for referring new place hosts and $150 reward for referring new experience hosts to the company's $0 reward for referring new users.

So if the blame is not clear, or for any less innocent reason that justifies it, siding with the host -- or whichever side generates better revenue for the company -- by default would be a wise business decision. Even though it is not necessarily right.

This simple example is just one of the numerous environments where 3rd party bias can unfairly alter how disagreements are settled.

Trust Issue being Addressed - What do I think I have?

Disputes are resolved in an honest and fair way without 3rd party (corporate) interests influencing outcomes.

What it Does

By decentralizing disputes to one's peers, Harmonia ensures an open and fair dispute resolution.

The Arbitrator.sol contract is the capstone and sets up a platform where offers can be proposed and processed through completion. What makes it cool is the dispute resolution process.

Disputes are initially hoped to be worked out between the 2 parties involved (e.g. renter & landlord); but if they are not, they are opened up to be voted on by trusted dispute resolutionists.

In order to be a dispute resolutionists, users stake (lock up $ in) HAR, a fungible token. Resolutionists risk both their reputation and their stake when voting, and can be penalized for dishonest participation. For honest participation, resolutionists are rewarded with HAR.

Moving disputes to a blockchain means the votes are public.

So if I am a dispute resolutionist looking to avoid "dishonest participation", why not just look and vote the same as everybody else voted?

Well, to make sure dispute resolutionists are not influenced to vote a certain way based on how other dispute resolutionists vote, all votes are encrypted until the voting period has ended. At that time the private key is made public by being published on chain, so anyone can verify the results.

The goal of this is to make sure dispute resolutionists take time to review the contents of a dispute, and actually assess the situation, before voting.

Because they are not rewarded based on future earnings, and their voting records are public, dispute resolutionists are not motivated to vote with any intention other than "doing the right thing".

How it Works

Agreement is made - Offer accepted

  1. A offeror opens an offer Agreement (e.g. a rental contract stored on IPFS) to a offeree.
  2. The offeree accepts said Offer, and the Agreement is set.

Something goes wrong - Dispute opened

  1. One of the parties (offeror or offeree) feels something went wrong, and would like to be compensated accordingly.
    • That party opens a Dispute and becomes the Dispute's plantiff.
    • The other party, now the Dispute's defendant, is notified.
  2. The defendant has a few options: 1. Settle 2. Counter 3. Decline.
    • Settle: payment is transferred from the defendant's deposit to the plaintiff and the Dispute is over
    • Counter: a counter offer is submitted, and the plaintiff can either settle or decline
    • Decline: a voting period is opened so the Dispute can be settled by vote

They can't work it out - Peers vote

  1. Voters have staked HAR, enabling them to vote on disputes, and are rewarded with HAR for voting.
    • HAR is an ERC-20 fungible token.
    • All votes are FHE encrypted through NuCypher.
      • A private key (used for encrypting & decrypting the votes) is supplied by the plaintiff to the defendant as a dispute is opened.
      • This private key is made public once the voting period has ended.
    • Voters are rewarded for "good behavior" and punished for "bad behavior".
      • Example: Alice rented Lee's apartment for a week and brought her dogs even though the agreement clearly stated "no pets allowed". Evidence includes videos from Ring of Alice walking in and out of the apartment with her 2 German Shepherds numerous times over the course of the week, including overnight stays.
      • Example "good behavior": voting Alice is in the wrong
      • Example "bad behavior"s: voting that Lee is in the wrong; manipulating the system to assist Alice or Lee

Voting ends - Open resolution reached

  1. The voting period ends, the plaintiff and defendant decrypt and count the votes, and the private key is made public on chain.
  2. Once the votes have been tallied and verified by the plaintiff and defendant, payment (if applicable) is transferred from one party to the other.
    • If the 2 parties disagree on the vote's results, that is something worth knowing.

Architecture diagram

Getting Started

On SKALE

git clone https://github.com/gumdropsteve/Harmonia

cd Harmonia

npm install

npm install -g truffle

truffle compile

truffle migrate --reset --network skale -f 2

Adding SKALE to Metamask

https://skale.network/docs/developers/wallets/getting-started#metamask

  1. Add a Custom RPC Network
  2. Network URL: https://eth-global-0.skalenodes.com:10456
  3. Chain ID: 0xb9454a5c40f66

Unit tests

To run the unit testing scripts

truffle test ./test/Arbitrator_test.js

truffle test ./test/Token_test.js

Tech Used

IPFS

A peer-to-peer hypermedia protocol designed to make the web faster, safer, and more open.

We used IPFS to store Agreement.documents, Dispute.plantiffEvidence and Dispute.defendantEvidence files.

NuCypher

A decentralized threshold cryptography network offering interfaces and runtimes for secrets management and dynamic access control.

We used NuCypher to help keep votes private while the voting period is live so that voters are not influenced by other voters, while allowing plaintiffs and defendants to decrypt votes to see results.

SKALE

Decentralized modular environment for Solidity dApps. Elastic Network for Ethereum Scaling.

We used SKALE to eliminate gas fees, reduce costs, and accelerate transaction speeds.

Future Direction

This dispute resolution contract was originally thought of as part of a decentralized real estate rental service, making AirBnb like disputes between guests and hosts more transparent and honest.