Skip to content

Commit 070cb24

Browse files
committed
Beem submission for NFT for financial applications
1 parent 8e66fcb commit 070cb24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+9468
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
noremap <Leader>f :!scrypto fmt<cr><cr>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "moonwork"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
8+
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
9+
10+
[dev-dependencies]
11+
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
12+
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
13+
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.6.0" }
14+
15+
[profile.release]
16+
opt-level = 's' # Optimize for size.
17+
lto = true # Enable Link Time Optimization.
18+
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
19+
panic = 'abort' # Abort on panic.
20+
strip = "debuginfo" # Strip debug info.
21+
overflow-checks = true # Panic in the case of an overflow.
22+
23+
[lib]
24+
crate-type = ["cdylib", "lib"]
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# MoonWork - Decentralised Freelancer Platform
2+
3+
## Whats The Problem and Usecase?
4+
Freelancer platforms have been very popular allowing people to work from anywhere and likewise for those that want work done quickly, freelancer platforms are a quick solution.
5+
Lets imagine some work was done for a project but in the end, the client refused to pay out.
6+
This is an all too common problem we have. What if, as a contractor, you were also judged unfairly due to external reasons.
7+
Reviews are also hard to completely judge on your own, can be spoofed, made up etc. This presents a few problems with freelancer platforms.
8+
Now lets have a look at what use cases NFTs would have in this space for what `MoonWork` provides.
9+
10+
## Why use NFTs and Decentralise Freelancer Platforms?
11+
NFTs (in my opinion) are the perfect use case for this, the advantages of using these are:
12+
1. Transparency - NFTs are public resources anyone can look into the ledger for.
13+
2. Verification - You can verify NFT metadata by verifying resource NFTs (more on this later).
14+
3. Immutability - NFTs can have some fields completely immutable and others mutable, this gives us confidence metadata is not able to be changed.
15+
16+
## What is MoonWork?
17+
Taking the features above, what `MoonWork` does are the following, split by contractors, clients and disputes and the use of NFTs:
18+
19+
### Contractors
20+
1. User registers as a contractor and receives a Contractor NFT which represents their MoonWork identity
21+
2. Newly registered contractors also get a ContractorAccolades NFT. Which all contractors get initially
22+
23+
When work gets completed, the following happens:
24+
1. For every successfully created work, a contractor's total worth increases, their Contractor NFT gets updated
25+
2. Contractors get rewarded a `WorkCompleted` NFT minted and is a **souldbound** NFT
26+
3. For every 10 `WorkCompleted`, Contractor gets a new `ContractorAccolades` NFT minted with all work non fungible id they completed to achieve it
27+
4. You can verify a Contractor's work by looking at their wallet balance for `WorkCompleted` and `ContractorAccolades` and verify the jobs completed matches the corresponding resources
28+
29+
When a dispute occurs and is completed:
30+
1. Contractors will get a `DisputeOutcome` NFT
31+
2. Contractor NFT also gets updated with the number of disputes they've been involved in
32+
3. In the same way, we can also verify the number of disputes by verifying it matches the balance of their `DisputeOutcome` NFT
33+
34+
### Clients
35+
1. User registers as a client.
36+
2. Clients can create new work based on a category (Development & IT, Accounting & Finance etc.)
37+
3. Contractors then request to take a Client's work
38+
4. Client then accepts a Contractor they wish to work with
39+
5. For a completed work, the Client's identity gets updated alongside the work they raised
40+
41+
When a dispute occurs and is completed:
42+
43+
1. Clients will get a `DisputeOutcome` NFT
44+
2. Client NFT also gets updated with the number of disputes
45+
3. In the same way, we can also verify the number of disputes by verifying it matches the balance of their `DisputeOutcome` NFT
46+
47+
### Dispute System
48+
1. A dispute is created with a participant criteria. In this case, for MoonWork, we have specific criteria:
49+
1. Participant limit - this is a limit of `Client` **AND** `Contractor` that can join and decide a dispute. For example, if participant limit is 2, we allow 2 clients and 2 contractors to join and decide a dispute
50+
2. Client criteria - this is a criteria a client has to meet, in this case, the number of jobs paid out
51+
3. Contractor criteria - this is a criteria a contractor has to meet, in this case, the number of jobs completed
52+
53+
2. Either a Client or Contractor can raise a dispute for work that has been assigned to them.
54+
1. Disputes can be cancelled by the one who raised it
55+
3. The client and contractor present their case by submitting `DisputeDocument` NFT which is viewable to the public. Its at their discretion to censor private information from documents.
56+
4. Participants join and decide based on the documents submitted
57+
5. Disputes can be completed if either:
58+
1. The time has expired and there is a majority vote
59+
2. If the majority vote has been given with participant limit reached
60+
6. In cases where both those conditions above do not apply, i.e. an undecided decision due to split votes, the admin then takes over and has final decision
61+
62+
### Promotion System
63+
This is a promotion system for contractors, where given their efforts of using the platform, they can, for a period of time,
64+
promote themselves which would appear on a "recommended" section on a frontend.
65+
The purpose of this system is really to show off the utility of the NFTs as a result of work being completed.
66+
The WorkCompleted and ContractorAccolades NFTs form the contractor's identity.
67+
68+
### Enough Talk! I Want To See It In Action!
69+
70+
#### Work Scenario - Completed Work
71+
Run through a happy path for work raised which does the following:
72+
- Creates the MoonWork service as an Admin
73+
- Registers an account as a Contractor
74+
- Registers an account as a Client
75+
- Creates a bunch of work categories as an Admin
76+
- Client creates a bunch of work in each cateogry as a Client
77+
- Contractor requests for said work raised by Client
78+
- Client accepts contractor for work
79+
- Client & Contractor accept to finish work
80+
- Finally Contractor can claim their compensation
81+
82+
```bash
83+
resim reset
84+
source ./transactions/run_full_flow.sh
85+
```
86+
87+
#### Dispute Scenario - Completed Dispute
88+
Run through disputes being completed successfully. The above steps must be run for disputes flow to work correctly:
89+
- Creates a dispute as a Client
90+
- Contractor and client submits documents
91+
- Other contractors and clients join and decide on the dispute
92+
- Majority vote is given and the dispute is completed as a Contractor
93+
94+
```bash
95+
source ./transactions/dispute/run_full_flow.sh
96+
```
97+
98+
#### Promotion Scenario - Promote Contractor
99+
Once again, like the above, run the Work Scenario first before running promotion flow:
100+
- Creates a promotion service as an admin
101+
- Contractor promotes themselves as a Contractor
102+
- Sets epoch and removes expired promotion
103+
104+
```bash
105+
source ./transactions/promotion/run_full_flow.sh
106+
```
107+
108+
### Thats Great, What About Alternative Cases?
109+
110+
We got you covered on this front luckily! So this is easy to test, instead of messing around with a bunch of bash environment variables, just run tests instead!
111+
112+
**Spoiler, there are 52 integration tests in total :D**
113+
114+
#### Running Tests
115+
```
116+
scrypto test
117+
```
118+
119+
## Read Documentation
120+
You can generate docs by running:
121+
122+
Install http and run a local server that serves the docs locally:
123+
```
124+
cargo install https
125+
cargo doc && target/doc
126+
```
127+
### Components
128+
129+
1. <a href="http://localhost:8000/moonwork/moonwork/MoonWorkService_impl/struct.MoonWorkService.html" target="_blank">MoonWorkService</a>
130+
2. <a href="http://localhost:8000/moonwork/work/WorkService_impl/struct.WorkService.html" target="_blank">WorkService</a>
131+
3. <a href="http://localhost:8000/moonwork/dispute/DisputeService_impl/struct.DisputeService.html" target="_blank">DisputeService</a>
132+
4. <a href="http://localhost:8000/moonwork/promotion/PromotionService_impl/struct.PromotionService.html" target="_blank">PromotionService</a>

0 commit comments

Comments
 (0)