Skip to content

Commit

Permalink
Update ERC-7750: Move to Review
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
jamesavechives authored Feb 9, 2025
1 parent bdd5269 commit 99c224b
Showing 1 changed file with 156 additions and 34 deletions.
190 changes: 156 additions & 34 deletions ERCS/erc-7750.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Decentralized Employment System
description: An employment system that records employment history.
author: James Savechives (@jamesavechives) <[email protected]>
discussions-to: https://ethereum-magicians.org/t/erc-7750-decentralized-employment-system-des/20724
status: Draft
status: Review
type: Standards Track
category: ERC
created: 2024-08-04
Expand Down Expand Up @@ -290,39 +290,161 @@ interface IDecentralizedEmploymentSystem {

## 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.
1. **Company Creation**

**Input**
- A user calls `registerCompany("TechCorp", "Technology")`.

**Expected State Changes**
- A new `companyId` is generated (e.g., `companyId = 1`).
- The `companies` mapping is updated:
```solidity
companies[1]↦{
name="TechCorp",
industry="Technology",
owner=callerAddress,
employeeIds=[ ]
}
```
- An event `CompanyRegistered` is emitted with the arguments `(1, callerAddress, "TechCorp", "Technology")`.

**Expected Output**
- **Return Value**: `companyId = 1` (the newly created company ID).
- **Event**: `CompanyRegistered` is logged.

2. **Employee Token Minting**

**Input**
- The contract owner (or an authorized address) calls `mintEmployeeToken(employeeAddress, "ipfs://metadataURI")`.

**Expected State Changes**
- A new token ID is generated (e.g., `tokenId = 5`).
- An internal mapping (e.g., `employeeTokenToOwner`) is updated:
```solidity
employeeTokenToOwner[5]↦employeeAddress
```
- (Optional) If the implementation tracks metadata, another mapping (e.g., `employeeTokenMetadata`) might store:
```solidity
employeeTokenMetadata[5]↦"ipfs://metadataURI"
```
- An event `EmployeeTokenMinted` is emitted with `(5, employeeAddress)`.

**Expected Output**
- **Return Value**: `tokenId = 5` (the newly minted employee token ID).
- **Event**: `EmployeeTokenMinted` is logged.

3. **Contract Creation and Execution**

**Input**
1. A company with `companyId = 1` calls:
```solidity
createContract(1,5,1000,6,"SoftwareDevelopment","Failuretomeetdeadlines")
```
which returns `contractId`.
2. Both the company and the employee call `executeContract(contractId)`.

**Expected State Changes**
- **Contract Creation**:
1. A new labor contract ID is generated, e.g., `contractId = 10`.
2. The `contracts` mapping is updated:
```solidity
contracts[10]↦{
companyId=1,
employeeTokenId=5,
salary=1000,
duration=6,
responsibilities="SoftwareDevelopment",
terminationConditions="Failuretomeetdeadlines",status="Created"
}
```
3. The system may also update a per-company or per-employee tracking structure (optional but typical):
```solidity
companyContracts[1].push(10)
employeeContracts[5].push(10)
```
4. An event `ContractCreated` is emitted with arguments `(10, 1, 5, 1000, 6)`.
- **Contract Execution**:
1. Upon calls from both parties, the contract’s status changes from `"Created"` to `"Active"`:
```solidity
contracts[10].status↦"Active"
```
2. An event `ContractExecuted` is emitted with `(10)` once both signatures/confirmations are received.
**Expected Output**
- **Return Value** (from `createContract`): `contractId = 10`
- **Event**: `ContractCreated(10, 1, 5, 1000, 6)` upon creation.
- **Event**: `ContractExecuted(10)` once execution is confirmed by both parties.
4. **Salary Deposit**
**Input**
- The company (owner of `companyId = 1`) calls `depositSalary(10)` and sends `1000 USDC` (or equivalent in wei for an [ERC-20](./eip-20.md) token or native token) to the contract.
**Expected State Changes**
1. The contract’s escrow balance mapping is updated:
```solidity
escrowBalances[10]↦1000
```
2. An event `SalaryDeposited` is emitted with `(10, 1000)`.

**Expected Output**
- **Event**: `SalaryDeposited(10, 1000)`
- The contract’s internal `escrowBalances[10]` should now be `1000`.

5. **Salary Payment**

**Input**
- After the contract’s duration or satisfaction of any release condition, `releaseSalary(10)` is called (by the contract or the employee).

**Expected State Changes**
1. The escrow balance for `contractId = 10` is transferred to the employee token owner (`employeeAddress` associated with token ID `5`).
2. The `escrowBalances[10]` is set to `0`:
```solidity
escrowBalances[10]↦0
```
3. An event `SalaryReleased` is emitted with `(10, employeeAddress)`.

**Expected Output**
- **Event**: `SalaryReleased(10, employeeAddress)`
- The updated `escrowBalances[10]` is now `0`.
- The employee’s on-chain balance (or token balance if using [ERC-20](./eip-20.md)) increases by `1000`.

6. **Employment Termination**

**Input**
- The company calls `terminateContract(10, "Failure to meet deadlines")`.

**Expected State Changes**
1. The `contracts[10].status` is updated to `"Terminated"`:
```solidity
contracts[10].status↦"Terminated"
```
2. An event `ContractTerminated` is emitted with `(10, "Failure to meet deadlines")`.

**Expected Output**
- **Event**: `ContractTerminated(10, "Failure to meet deadlines")`
- The `contracts[10]` status is now `"Terminated"`.
- No further salary obligations exist unless otherwise specified in dispute-resolution processes.

7. **Dispute Resolution**

**Input**
1. Either party (company or employee) calls `raiseDispute(10)`.
2. The assigned moderator calls `resolveDispute(10, true)` indicating the decision favors the employee.

**Expected State Changes**
- **Dispute Raised**:
1. The contract’s dispute status is noted (implementation-specific, but typically `contracts[10].disputeRaised = true`).
2. An event `DisputeRaised(10, msg.sender)` is emitted.
- **Dispute Resolved**:
1. If `decisionForEmployee == true`, any remaining escrow funds for `contractId = 10` are transferred to the employee.
2. A `DisputeResolved(10, true)` event is emitted.

**Expected Output**
- **Event**: `DisputeRaised(10, msg.sender)`
- **Event**: `DisputeResolved(10, true)`
- If funds remain in escrow, `escrowBalances[10]` is set to `0`, and the employee receives the outstanding balance.


## Security Considerations

Expand Down

0 comments on commit 99c224b

Please sign in to comment.