Untitled
unknown
plain_text
3 years ago
2.0 kB
2
Indexable
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; contract MyContract { using SafeMath for uint; address public owner; address public developer; address public client; uint public projectAmount; uint public contractFee; uint contractTime; constructor(address _developer, address _client, uint _projectAmount, uint _contractFee) { owner = msg.sender; developer = _developer; client = _client; projectAmount = _projectAmount; contractFee = _contractFee; contractTime = block.timestamp; } event gotPayment(address indexed from , address indexed to, uint payment); modifier onlyOwner{ require(msg.sender == owner , "you can not call this function"); _; } modifier onlyDeveloper{ require(msg.sender == developer , "you can not call this function"); _; } modifier onlyClient{ require(msg.sender == client , "you can not call this function"); _; } modifier onlyAfter{ require(contractTime + 30 days <= block.timestamp , "you can not call this function"); _; } function getBalance() public view returns(uint){ return address(this).balance; } function makePayment() public payable onlyClient { require(msg.value >= projectAmount , "please deposit project amount"); emit gotPayment(msg.sender, address(this) , msg.value); } function withdrawPayment() public onlyDeveloper onlyAfter { uint getContractFee = address(this).balance.div(5); uint finalPayment = address(this).balance.sub(getContractFee); payable(developer).transfer(finalPayment); emit gotPayment(address(this), developer , finalPayment); } function ownerWithdraw(address payable _to) public onlyOwner{ _to.transfer(getBalance()); } }
Editor is loading...