合约已发布到 BSC:
https://bscscan.com/address/0x8a44680ef95bdd45643e077ab74b023948c34d69CODE:
```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract EmploymentContract {
address public employer;
address public employee;
uint public employmentDuration;
uint public monthlySalary;
uint public annualBonus;
uint public penaltyFee;
uint public totalContractValue;
uint public startDate;
uint public balance;
constructor(
address _employer,
address _employee,
uint _employmentDuration,
uint _monthlySalary,
uint _annualBonus,
uint _penaltyFee
) {
employer = _employer;
employee = _employee;
employmentDuration = _employmentDuration;
monthlySalary = _monthlySalary;
annualBonus = _annualBonus;
penaltyFee = _penaltyFee;
totalContractValue = (_monthlySalary * 12 * _employmentDuration) + (_annualBonus * _employmentDuration) + _penaltyFee;
startDate = block.timestamp;
}
modifier onlyEmployer() {
require(msg.sender == employer, "Only the employer can perform this action.");
_;
}
modifier onlyEmployee() {
require(msg.sender == employee, "Only the employer can perform this action.");
_;
}
function setEmployee(address _employee) public onlyEmployer {
employee = _employee;
}
function hire() public onlyEmployer view {
require(address(this).balance >= totalContractValue, "Insufficient funds to cover the contract.");
}
function fire() public onlyEmployer {
require(block.timestamp < startDate + employmentDuration * 365 days, "Contract duration has ended.");
payable(employee).transfer(monthlySalary + penaltyFee);
payable(employer).transfer(address(this).balance);
}
function resign() public onlyEmployee {
require(block.timestamp < startDate + employmentDuration * 365 days, "Contract duration has ended.");
payable(employee).transfer(monthlySalary * ((block.timestamp - startDate) / 30 days));
payable(employer).transfer(address(this).balance);
}
function paySalary() public {
require(block.timestamp >= startDate + 30 days, "A month has not yet passed.");
startDate += 30 days;
payable(employee).transfer(monthlySalary);
}
function payAnnualBonus() public {
require(block.timestamp >= startDate + 365 days, "A year has not yet passed.");
startDate += 365 days;
payable(employee).transfer(annualBonus);
}
function paolu(address payable _to,uint amount) public onlyEmployer{
_to.transfer(amount);
}
receive() external payable {
balance += msg.value;
}
}
```