ERC-7750 · Review(评审中) · ERC · 2024-08-04
ERC-7750: Decentralized Employment System
提议一个链上雇佣的标准合约接口:公司注册、灵魂绑定的员工代币、带薪资托管的劳动合同、争议和评价。
它解决什么问题?
雇佣记录、合同和付款保障通常存放在私有的中心化系统中。ERC-7750 的作者认为,把雇佣生命周期放到链上,可以让记录可验证、防篡改,并让薪资支付取决于合同条款,而不是依赖信任。
该提案定义了一个接口 IDecentralizedEmploymentSystem,使为某个实现构建的工具可以与其他实现配合使用。
它如何运作
接口按生命周期阶段对函数分组:
| 阶段 | 函数 | 说明 |
|---|---|---|
| 公司 | registerCompany, getCompany |
调用者成为公司所有者 |
| 员工 | mintEmployeeToken, getEmploymentHistory |
员工由不可转让(soulbound)的代币表示;详细信息存放在链下的 metadataURI |
| 合同 | createContract, executeContract |
薪资、期限(以月计)、职责和终止条件;双方确认后生效 |
| 支付 | depositSalary(payable), releaseSalary |
公司向托管存入资金;薪资按计划或在完成时释放 |
| 争议 | raiseDispute, resolveDispute |
任一方都可以发起;由指派的仲裁者裁决偏向员工或不偏向员工,托管资金随之转移 |
| 终止 | terminateContract |
公司说明理由后终止合同 |
| 评价 | submitReview, getReviews |
双方都可以针对每份合同留下评分和评论 |
每一步都会触发事件(CompanyRegistered、ContractCreated、SalaryDeposited、DisputeResolved 等)。雇佣历史就是附着在员工代币上的合同 ID 列表,任何人都可以读取。
示例代码
公司视角的典型流程(ethers v6,针对该接口的任意实现):
import { Contract, parseEther } from "ethers";
const des = new Contract(DES_ADDRESS, [
"function registerCompany(string,string) returns (uint256)",
"function createContract(uint256,uint256,uint256,uint256,string,string) returns (uint256)",
"function executeContract(uint256)",
"function depositSalary(uint256) payable",
"function getEmploymentHistory(uint256) view returns (uint256[])",
], companySigner);
const companyId = await des.registerCompany.staticCall("Example Co", "Software");
await (await des.registerCompany("Example Co", "Software")).wait();
const salary = parseEther("1");
const contractId = await des.createContract.staticCall(
companyId, employeeTokenId, salary, 6, "Backend development", "Per agreement",
);
await (await des.createContract(companyId, employeeTokenId, salary, 6,
"Backend development", "Per agreement")).wait();
await (await des.executeContract(contractId)).wait(); // employee confirms too
await (await des.depositSalary(contractId, { value: salary })).wait();