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.
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.
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:
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;
}
}
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.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.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.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.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.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.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.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.
Public Accessibility: Employment history data is publicly accessible through the getEmploymentHistory
function, allowing companies to verify an employee's past engagements before finalizing contracts.
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.
Automated Payments: Salaries are released automatically or upon triggering the releaseSalary
function, ensuring timely and condition-based payments to employees.
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.
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.
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.
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.
Review System:
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.
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.
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.
Input
- The company (owner of companyId = 1
) calls depositSalary(10)
and sends 1000 USDC
(or equivalent in wei for an ERC-20 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
.
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) increases by 1000
.
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.
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.
Contract Integrity: Ensure that all labor contracts are immutable and cannot be tampered with once created and executed.
Fund Security: Salaries are securely held in escrow, and only released based on predefined conditions to prevent unauthorized access or misuse.
Moderator Trust: Implement a decentralized and transparent system for selecting and monitoring moderators to maintain impartiality and trust in dispute resolutions.
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.
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 and related rights waived via CC0.