Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC: Decentralized Employment System #573

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8846871
Multi Owners NFT
Jul 13, 2024
f19cb42
correct format
Jul 13, 2024
9b73e1b
correct format
Jul 13, 2024
18c8be9
correct format
Jul 13, 2024
2490372
correct format
Jul 13, 2024
d591c27
update format
Jul 13, 2024
910b33a
change format
Jul 13, 2024
acf7094
update format
Jul 13, 2024
de9d3b0
update Author
Jul 16, 2024
a34f31e
Merge pull request #1 from jamesavechives/MO-NFT
jamesavechives Jul 16, 2024
b945e47
Merge branch 'master' into MO-NFT
jamesavechives Jul 16, 2024
daadfeb
Merge branch 'ethereum:master' into master
jamesavechives Jul 17, 2024
3e9fb18
update epi number to 7743
Jul 17, 2024
9ad648e
Merge branch 'MO-NFT' of github.com:jamesavechives/ERCs into MO-NFT
Jul 17, 2024
aa9b515
Merge pull request #2 from jamesavechives/MO-NFT
jamesavechives Jul 17, 2024
26006c3
Add ERC : Decentralized Employment System
Aug 4, 2024
1f40d4b
change file name
Aug 4, 2024
995c726
update format
Aug 4, 2024
d58050d
update format
Aug 4, 2024
ce35b5d
update format
Aug 4, 2024
f15ed1f
Merge branch 'master' into DES
jamesavechives Aug 4, 2024
0fdf84e
Merge branch 'master' into DES
jamesavechives Aug 6, 2024
4b0bddf
eip number and discussion link
Aug 6, 2024
3761bee
Merge branch 'master' into DES
jamesavechives Aug 9, 2024
69445bc
Merge branch 'master' into DES
jamesavechives Aug 19, 2024
e1f086f
Update ERCS/erc-7750.md
jamesavechives Sep 29, 2024
b21a484
Update ERCS/erc-7750.md
jamesavechives Sep 29, 2024
f68729f
update specification
Oct 1, 2024
c307af6
Merge branch 'master' into DES
jamesavechives Oct 8, 2024
f4e9d5d
Employee Tokenization
Oct 8, 2024
c056b0e
update rationale section
Oct 8, 2024
de4faab
update tests section
Oct 8, 2024
ea4cc64
update format
Oct 8, 2024
6294e6b
Update ERC: Remove email & format document
Nov 28, 2024
f8a1005
Merge branch 'ethereum:master' into master
jamesavechives Nov 28, 2024
8b56acd
Update ERC-7743: Move to Review
Nov 28, 2024
ca2bc09
Merge branch 'master' into master
jamesavechives Dec 1, 2024
4030850
Merge branch 'ethereum:master' into master
jamesavechives Dec 7, 2024
97f0f7b
Merge branch 'master' into master
jamesavechives Dec 11, 2024
77f5cad
remove private members in specification section
Dec 11, 2024
bebc198
Merge branch 'master' into master
jamesavechives Dec 12, 2024
6f02563
Merge branch 'master' into master
jamesavechives Dec 15, 2024
f1e71d4
Merge branch 'master' into master
jamesavechives Dec 20, 2024
5a3d04c
Merge branch 'ethereum:master' into master
jamesavechives Dec 24, 2024
6565b28
Merge pull request #4 from jamesavechives/master
jamesavechives Dec 24, 2024
8943c58
revert for other erc
Dec 24, 2024
68c3a5a
revert changes for other ERC
Dec 24, 2024
479343a
revert from monft
Dec 24, 2024
44b2e36
Merge pull request #5 from jamesavechives/pure
jamesavechives Dec 24, 2024
e225df2
add more details
Dec 24, 2024
cc4bce3
update format
Dec 24, 2024
961b2a5
update format
Dec 24, 2024
de53926
Merge branch 'master' into DES
jamesavechives Dec 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
342 changes: 342 additions & 0 deletions ERCS/erc-7750.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
---
eip: 7750
title: Decentralized Employment System
description: An employment system that records employment history.
jamesavechives marked this conversation as resolved.
Show resolved Hide resolved
author: James Savechives (@jamesavechives) <james.walstonn@gmail.com>
discussions-to: https://ethereum-magicians.org/t/erc-7750-decentralized-employment-system-des/20724
status: Draft
type: Standards Track
category: ERC
created: 2024-08-04
---

## Abstract

This ERC proposes a Decentralized Employment System (DES) built on the Ethereum blockchain. The DES facilitates the creation and management of companies, records comprehensive employment histories through unique employee tokens, enables the formation and execution of labor contracts, automates salary payments via an escrow mechanism, incorporates a robust moderation system for dispute resolution, and implements a reputation-based review system for both employers and employees. By leveraging blockchain's transparency and immutability, the DES ensures accountability and trust throughout the employment lifecycle, from company creation and hiring to contract fulfillment and termination.

The system operates post employee testing and prior to the final hiring and contract signing. Employees possess a **Soulbound Token (SBT)** representing their employment history, which companies review before finalizing labor contracts. This token-based approach ensures a secure and verifiable employment record that enhances the hiring process's integrity.

## Motivation

Traditional employment systems are centralized, opaque, and often lack trust. The DES aims to introduce transparency, immutability, and trust into the employment process by leveraging blockchain technology. By recording employment history on-chain, enabling decentralized company creation, automating contract enforcement, and providing mechanisms for dispute resolution, the DES promotes a fairer and more transparent employment ecosystem. Additionally, the system streamlines the hiring process by securely managing employment records and automating contractual obligations.

## Specification

### Solidity Interface

To provide a clear and standardized way for developers to interact with the DES, the following Solidity interface outlines the primary functions and events of the system:

```solidity
pragma solidity ^0.8.0;

/// @title Decentralized Employment System Interface
interface IDecentralizedEmploymentSystem {

// Events
event CompanyRegistered(uint companyId, address owner, string name, string industry);
event EmployeeTokenMinted(uint tokenId, address employee);
event ContractCreated(uint contractId, uint companyId, uint employeeTokenId, uint salary, uint duration);
event ContractExecuted(uint contractId);
event SalaryDeposited(uint contractId, uint amount);
event SalaryReleased(uint contractId, address employee);
event DisputeRaised(uint contractId, address raisedBy);
event DisputeResolved(uint contractId, bool decisionForEmployee);
event ContractTerminated(uint contractId, string reason);
event ReviewSubmitted(uint contractId, uint rating, string comments);

// Company Management
function registerCompany(string calldata name, string calldata industry) external returns (uint companyId);
function getCompany(uint companyId) external view returns (string memory name, string memory industry, address owner, uint[] memory employeeIds);

// Employee Management
function mintEmployeeToken(address employee, string calldata metadataURI) external returns (uint tokenId);
function getEmploymentHistory(uint employeeTokenId) external view returns (uint[] memory contractIds);

// Labor Contracts
function createContract(uint companyId, uint employeeTokenId, uint salary, uint duration, string calldata responsibilities, string calldata terminationConditions) external returns (uint contractId);
function executeContract(uint contractId) external;

// Payment System
function depositSalary(uint contractId) external payable;
function releaseSalary(uint contractId) external;

// Dispute Resolution
function raiseDispute(uint contractId) external;
function resolveDispute(uint contractId, bool decisionForEmployee) external;

// Contract Termination
function terminateContract(uint contractId, string calldata reason) external;

// Review System
function submitReview(uint contractId, uint rating, string calldata comments) external;
function getReviews(uint contractId) external view returns (Review[] memory);

// Structures
struct Review {
uint rating;
string comments;
address reviewer;
}
}
```

### Detailed Function Specifications

#### 1. Company Management

**a. Company Registration**

- **Function**: `registerCompany(string calldata name, string calldata industry) external returns (uint companyId)`

- **Description**: Allows users to register a new company on the blockchain. Each company is assigned a unique `companyId` and associated with the caller's address as the owner.

- **Parameters**:
- `name`: The name of the company.
- `industry`: The industry sector of the company.

- **Returns**:
- `companyId`: A unique identifier for the registered company.

**b. Retrieve Company Profile**

- **Function**: `getCompany(uint companyId) external view returns (string memory name, string memory industry, address owner, uint[] memory employeeIds)`

- **Description**: Retrieves the profile details of a registered company, including its name, industry, owner address, and a list of associated employee token IDs.

- **Parameters**:
- `companyId`: The unique identifier of the company.

- **Returns**:
- `name`: Name of the company.
- `industry`: Industry sector of the company.
- `owner`: Ethereum address of the company owner.
- `employeeIds`: Array of employee token IDs associated with the company.

#### 2. Employee Management

**a. Employee Tokenization**

- **Function**: `mintEmployeeToken(address employee, string calldata metadataURI) external returns (uint tokenId)`

- **Description**: Mints a **Soulbound Token (SBT)** representing an employee. The token contains metadata about the employee, such as professional credentials, stored off-chain and referenced via `metadataURI`.

- **Parameters**:
- `employee`: Ethereum address of the employee.
- `metadataURI`: URI pointing to the employee's metadata.

- **Returns**:
- `tokenId`: A unique identifier for the employee token.

**b. Retrieve Employment History**

- **Function**: `getEmploymentHistory(uint employeeTokenId) external view returns (uint[] memory contractIds)`

- **Description**: Fetches the complete employment history of an employee by returning an array of associated `contractIds`.

- **Parameters**:
- `employeeTokenId`: The unique identifier of the employee's token.

- **Returns**:
- `contractIds`: Array of contract IDs representing the employee's employment history.

#### 3. Labor Contracts

**a. Contract Creation**

- **Function**: `createContract(uint companyId, uint employeeTokenId, uint salary, uint duration, string calldata responsibilities, string calldata terminationConditions) external returns (uint contractId)`

- **Description**: Enables a company to create a new labor contract with an employee. This function assigns a unique `contractId` to the contract.

- **Parameters**:
- `companyId`: The unique identifier of the company initiating the contract.
- `employeeTokenId`: The unique identifier of the employee's token.
- `salary`: The agreed-upon salary for the contract period.
- `duration`: Duration of the contract in months.
- `responsibilities`: Description of the employee's responsibilities.
- `terminationConditions`: Conditions under which the contract can be terminated.

- **Returns**:
- `contractId`: A unique identifier for the newly created contract.

**b. Contract Execution**

- **Function**: `executeContract(uint contractId) external`

- **Description**: Activates the contract by marking it as active once both the company and the employee have agreed to the terms by signing the transaction with their respective wallets.

- **Parameters**:
- `contractId`: The unique identifier of the contract to be executed.

#### 4. Payment System

**a. Salary Deposits**

- **Function**: `depositSalary(uint contractId) external payable`

- **Description**: Allows the company to deposit the agreed salary into the contract's escrow. The function ensures that the deposited amount matches the contract's salary.

- **Parameters**:
- `contractId`: The unique identifier of the contract for which the salary is being deposited.

- **Payable**: Yes, the function is payable to accept the salary funds.

**b. Automated Payments**

- **Function**: `releaseSalary(uint contractId) external`

- **Description**: Releases the salary from escrow to the employee's address based on the contract's payment schedule or upon contract completion.

- **Parameters**:
- `contractId`: The unique identifier of the contract for which the salary is being released.

#### 5. Dispute Resolution

**a. Dispute Initiation**

- **Function**: `raiseDispute(uint contractId) external`

- **Description**: Allows either party involved in the contract to initiate a dispute. This action triggers the assignment of a moderator to resolve the issue.

- **Parameters**:
- `contractId`: The unique identifier of the contract in dispute.

**b. Dispute Resolution**

- **Function**: `resolveDispute(uint contractId, bool decisionForEmployee) external`

- **Description**: Enables the assigned moderator to resolve the dispute by making a decision. If the decision favors the employee, escrow funds are transferred accordingly; otherwise, they may be returned to the company.

- **Parameters**:
- `contractId`: The unique identifier of the contract under dispute.
- `decisionForEmployee`: Boolean indicating if the decision favors the employee.

#### 6. Contract Termination

**a. Termination Conditions**

- **Function**: `terminateContract(uint contractId, string calldata reason) external`

- **Description**: Allows the company to terminate the contract based on predefined conditions. This function updates the contract status to "terminated."

- **Parameters**:
- `contractId`: The unique identifier of the contract to be terminated.
- `reason`: The reason for termination.

#### 7. Review System

**a. Submit Review**

- **Function**: `submitReview(uint contractId, uint rating, string calldata comments) external`

- **Description**: Enables both companies and employees to submit reviews post-contract. Reviews include a rating and comments, contributing to the reputation score of both parties.

- **Parameters**:
- `contractId`: The unique identifier of the contract being reviewed.
- `rating`: Numerical rating reflecting the experience.
- `comments`: Detailed feedback about the contract.

**b. Retrieve Reviews**

- **Function**: `getReviews(uint contractId) external view returns (Review[] memory)`

- **Description**: Retrieves all reviews associated with a specific contract.

- **Parameters**:
- `contractId`: The unique identifier of the contract whose reviews are being fetched.

- **Returns**:
- `Review[]`: An array of reviews related to the contract.

### Employment History

1. **Immutable Records**: Employment history is maintained as an array of contract IDs linked to each employee's Soulbound Token (SBT). This ensures that all employment records are permanently and immutably stored on the blockchain.

2. **Public Accessibility**: Employment history data is publicly accessible through the `getEmploymentHistory` function, allowing companies to verify an employee's past engagements before finalizing contracts.

### Payment System

1. **Salary Deposits**: Companies deposit salaries into an escrow managed by the smart contract by calling `depositSalary`. The contract ensures that funds are securely held until payment conditions are satisfied.

2. **Automated Payments**: Salaries are released automatically or upon triggering the `releaseSalary` function, ensuring timely and condition-based payments to employees.

### Moderation and Dispute Resolution

1. **Dispute Initiation and Resolution**: Either party can raise disputes, which are then resolved by assigned moderators. Moderators act as impartial arbitrators to ensure fair outcomes based on contract terms and evidence provided.

### Firing Employees

1. **Termination Conditions**: Companies can terminate contracts based on predefined conditions, with the option for dispute resolution if termination is contested.

### Review System

1. **Reputation Scores**: Reviews contribute to the reputation scores of both companies and employees, fostering accountability and encouraging positive behavior within the ecosystem.

## Rationale

1. **Employee Tokenization**:
- Utilizing **Soulbound Tokens (SBTs)** to represent employees ensures that each employee has a unique, non-transferable identity on the blockchain. This design choice enhances the integrity of employment records, making them tamper-proof and verifiable. It also allows companies to access a comprehensive employment history before finalizing contracts, promoting transparency.

2. **Escrow System for Salary Payments**:
- Implementing an escrow mechanism secures salary payments, ensuring that funds are only released when contractual obligations are met. This system protects both employees and companies by guaranteeing that salaries are available and that payments are contingent on contract fulfillment.

3. **Moderation and Dispute Resolution**:
- Incorporating a moderation system allows for the resolution of disputes that cannot be automatically enforced by smart contracts. Moderators provide necessary human oversight in complex employment matters, ensuring fair and just outcomes.

4. **Public Employment History**:
- Making employment history publicly accessible fosters trust and accountability. It allows potential employers to verify past employment and credentials, reducing the risk of fraud and enhancing the credibility of employees within the ecosystem.

5. **Review System**:
- A reputation-based review system encourages positive interactions and behaviors among users. By allowing both companies and employees to submit reviews, the system promotes mutual accountability and helps build reliable reputations.

## Test Cases

1. **Company Creation**:
- **Input**: A user calls the `registerCompany("TechCorp", "Technology")` function.
- **Expected Output**: A new company is registered with a unique `companyId`, and the `companies` mapping is updated with the company's details (name: "TechCorp", industry: "Technology", owner: caller's address).

2. **Employee Token Minting**:
- **Input**: The system owner calls `mintEmployeeToken(employeeAddress, "ipfs://metadataURI")`.
- **Expected Output**: A new SBT is minted for the employee with a unique `tokenId`, and the `employees` mapping is updated accordingly.

3. **Contract Creation and Execution**:
- **Input**:
1. A company with `companyId` `1` calls `createContract(1, 5, 1000, 6, "Software Development", "Failure to meet deadlines")`.
2. Both the company and the employee sign the contract by calling `executeContract(contractId)`.
- **Expected Output**:
1. A new labor contract is created with a unique `contractId`, and relevant mappings are updated.
2. The contract status is set to "active" upon execution by both parties.

4. **Salary Deposit**:
- **Input**: The company calls `depositSalary(contractId)` with a value of `1000 USDC`.
- **Expected Output**: The `escrowBalances` mapping is updated to reflect the deposited amount for `contractId`, securing the funds in escrow.

5. **Salary Payment**:
- **Input**: After the contract duration, `releaseSalary(contractId)` is called.
- **Expected Output**: The escrowed `1000 USDC` is transferred to the employee's address, and the `escrowBalances` mapping for `contractId` is reset to zero.

6. **Employment Termination**:
- **Input**: The company calls `terminateContract(contractId, "Failure to meet deadlines")`.
- **Expected Output**:
1. The contract status is updated to "terminated" in the `contracts` mapping.
2. A termination event is emitted, and the company is no longer obligated to continue salary payments.

7. **Dispute Resolution**:
- **Input**: Either party calls `raiseDispute(contractId)`, followed by the assigned moderator calling `resolveDispute(contractId, true)` to favor the employee.
- **Expected Output**: The escrow funds are transferred to the employee, and the dispute is marked as resolved in the contract's status.

## Security Considerations

1. **Contract Integrity**: Ensure that all labor contracts are immutable and cannot be tampered with once created and executed.

2. **Fund Security**: Salaries are securely held in escrow, and only released based on predefined conditions to prevent unauthorized access or misuse.

3. **Moderator Trust**: Implement a decentralized and transparent system for selecting and monitoring moderators to maintain impartiality and trust in dispute resolutions.

4. **Review System**: Incorporate safeguards against fraudulent reviews, such as verifying the association of reviews with legitimate contract completions, to maintain accurate and trustworthy reputation scores.

5. **Token Security**: Use **Soulbound Tokens (SBTs)** for employee representation to prevent token transfers and ensure that employment records are securely tied to the respective individuals.


## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).
Loading