Skip to content

anubhav-auth/DeWork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DeWork

DeWork is a decentralized freelance marketplace built on the Solana blockchain. It connects clients who need work done with workers who offer skills, replacing the role of a centralized intermediary with a transparent, programmable smart contract. All job lifecycle logic — posting, bidding, escrow, milestones, disputes, and payments — is enforced entirely on-chain.


Overview

Traditional freelance platforms act as trusted middlemen: they hold funds, arbitrate conflicts, and take a significant fee. DeWork replaces this with an Anchor-based Solana program. Funds are locked in a program-controlled escrow account when a proposal is accepted. They are only released to the worker when the client explicitly approves, or to the client if a dispute is resolved in their favor. No party — including the platform admin — can move funds outside of the defined instruction logic.

The repository is organized into two workspaces:

  • onchain/ — the Anchor/Rust smart contract program deployed to Solana
  • offchain-client/ — a Rust client using anchor-client to interact with the deployed program, demonstrating the full job lifecycle

Architecture

On-Chain Program (onchain/)

The program is identified by:

Program ID: FDp3JtCcWcsLBreHRdJC7dfuWtHVMhCNKfTApAbbt5EM

It is structured around eight instruction modules, each responsible for a distinct domain:

Module Responsibility
global_flow Initialize the platform's global state (fee, treasury, admin)
user_flow Register users as Client or Worker, manage worker profiles
company_flow Register and verify company entities; create and mint utility tokens
job_flow Post, update, cancel, and close job listings
proposal_flow Submit, update, withdraw proposals; accept a proposal and lock escrow
escrow_flow Release milestone payments to worker; refund client
dispute_flow Raise a dispute with evidence, assign an arbitrator, resolve with split or winner
admin_flow Manage arbitrator list; update platform fee (in basis points) and treasury address
rating_flow Submit a numeric review and comment after job completion

Off-Chain Client (offchain-client/)

A Rust binary (tokio-based async) that demonstrates end-to-end interaction with the on-chain program using anchor-client. It walks through the full happy path: airdrop → global state init → user and worker registration → worker profile creation → job posting with milestones → proposal submission → account data fetch. This serves as both integration test and usage reference.


On-Chain State

The program stores the following Program Derived Accounts (PDAs):

  • GlobalState — platform-wide config: admin, USDC mint, treasury address, platform fee in basis points, and job/user counters
  • UserAccount — per-wallet record with role (Client or Worker), registration timestamp, and active status
  • WorkerProfile — skill title, skill list, description, rate per job, and an active flag; seeded by [b"profile", worker_pubkey, index]
  • CompanyProfile — company name, metadata URI, and verification status
  • Job — title, description, required skills, budget, deadline, status (Open, InProgress, Completed, Cancelled, Disputed), and a list of Milestone structs
  • Milestone — per-milestone amount, description, and a boolean is_released flag
  • Proposal — proposed amount, pitch, worker reference, and status
  • Escrow — locked USDC amount tied to a specific job and worker
  • Dispute — evidence URI, assigned arbitrator, and resolution status
  • Review — numeric score and comment, linked to a job
  • ArbitratorList — admin-managed list of approved arbitrator public keys
  • TokenDiscount — optional struct on a job to apply a fee discount based on a utility token mint

Key Flows

Posting a Job

A registered Client calls post_job_main with a title, description, required skills, USDC budget, Unix deadline, and an optional list of milestones. Each milestone carries an amount and description. An optional TokenDiscount can be attached to reduce the platform fee for clients holding a specific utility token.

Submitting and Accepting a Proposal

A registered Worker with an active profile calls submit_proposal_main with a proposed USDC amount and a pitch. The client reviews and calls accept_proposal_and_initiate_escrow_main, which atomically marks the proposal as accepted and transfers the agreed USDC amount from the client's token account into a program-controlled escrow PDA.

Releasing Payment

The client calls release_payment_main. If milestones are defined, a milestone_index is provided and that specific milestone's amount is released. If no milestones exist, the full escrow amount is transferred to the worker's USDC token account, minus the platform fee which goes to the treasury.

Dispute Resolution

Either party can call raise_dispute_main with an IPFS or Arweave URI pointing to off-chain evidence. An admin then calls assign_arbitrator_main to assign a trusted arbitrator from the on-chain list. The arbitrator resolves the dispute by calling resolve_dispute_main with either a clear winner or a percentage split (client_percentage out of 100), after which the escrow is distributed accordingly.

Company and Utility Tokens

Companies can register with a name and metadata URI and become verified by an admin. Verified companies can create their own SPL utility token and mint supply to holders. Jobs can reference this token mint via TokenDiscount to offer reduced platform fees to clients who hold the token.


Prerequisites

For the On-Chain Program

For the Off-Chain Client

  • Rust (same toolchain)
  • A running Solana local validator (solana-test-validator)

Getting Started

1. Clone the Repository

git clone https://github.com/anubhav-auth/DeWork.git
cd DeWork

2. Build and Deploy the On-Chain Program

cd onchain
yarn install
anchor build
anchor deploy

This deploys the program to localnet using the wallet at ~/.config/solana/id.json. The program ID is FDp3JtCcWcsLBreHRdJC7dfuWtHVMhCNKfTApAbbt5EM.

3. Run Tests

anchor test

This spins up a local validator, deploys the program, and runs the TypeScript test suite under onchain/tests/.

4. Run the Off-Chain Client

In a separate terminal, start the local validator if it is not already running:

solana-test-validator

Then, from the repository root:

cd offchain-client
cargo run

The client will generate keypairs, request airdrops, and execute the full job lifecycle — printing transaction signatures to stdout at each step.


Project Structure

DeWork/
├── onchain/                        # Anchor workspace
│   ├── Anchor.toml
│   ├── programs/
│   │   └── onchain/
│   │       └── src/
│   │           ├── lib.rs          # Program entrypoint, all instruction dispatchers
│   │           ├── instructions/   # Instruction modules by domain
│   │           │   ├── admin_flow/
│   │           │   ├── company_flow/
│   │           │   ├── dispute_flow/
│   │           │   ├── escrow_flow/
│   │           │   ├── global_flow/
│   │           │   ├── job_flow/
│   │           │   ├── proposal_flow/
│   │           │   ├── rating_flow/
│   │           │   └── user_flow/
│   │           └── states/         # Account struct definitions
│   │               ├── global_state.rs
│   │               ├── user_account.rs
│   │               ├── worker_profile.rs
│   │               ├── company_profile.rs
│   │               ├── job.rs
│   │               ├── milestones.rs
│   │               ├── proposal.rs
│   │               ├── escrow.rs
│   │               ├── disputes.rs
│   │               ├── review.rs
│   │               ├── arbitrator_list.rs
│   │               ├── token_discount.rs
│   │               ├── error_codes.rs
│   │               └── enums/
│   └── tests/
└── offchain-client/                # Rust client binary
    └── src/
        └── main.rs

Platform Fee

The platform charges a configurable fee expressed in basis points (bps). The default used in the off-chain client demo is 200 bps (2%). The admin can update this at any time via update_platform_fee_main and redirect the treasury via update_treasury_address_main. Fees are collected into a USDC token account (the platform treasury) at the time of payment release.


License

This project is licensed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors