pragma solidity ^0.8.11; // SPDX-License-Identifier: UNLICENSED contract Crowdfunding{ address owner; uint public goal; uint public endtime; uint public total=0; mapping(address=>uint) gift; constructor(uint _goal, uint _time) { owner = msg.sender; goal = _goal; endtime = block.timestamp + _time; } function donate() payable public{ require(block.timestamp < endtime); require(total < goal); require(msg.value > 0); gift[msg.sender] += msg.value; total += msg.value; } function draw() public{ require(msg.sender == owner); require(total > goal); payable(owner).transfer(address(this).balance); } function uspeh() public view returns(bool){ if ((block.timestamp > endtime) && (total >= goal)) return true; else return false; } function timeleft() public view returns(uint){ return (endtime - block.timestamp); } function withdraw() public{ require(block.timestamp > endtime); require(total < goal); uint amount = gift[msg.sender]; total -= amount; gift[msg.sender] = 0; payable(address(msg.sender)).transfer(amount); } }