-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv0.standard-json.mainnet.json
More file actions
1 lines (1 loc) · 2.19 KB
/
v0.standard-json.mainnet.json
File metadata and controls
1 lines (1 loc) · 2.19 KB
1
{"language":"Solidity","sources":{"BaseFundV0.sol":{"content":"// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.24;\r\n\r\ncontract BaseFundV0 {\r\n address public owner;\r\n uint256 public goal;\r\n uint256 public deadline;\r\n uint256 public totalRaised;\r\n mapping(address => uint256) public contributions;\r\n\r\n event Contribution(address indexed backer, uint256 amount);\r\n event Refunded(address indexed backer, uint256 amount);\r\n event Withdrawn(address indexed owner, uint256 amount);\r\n\r\n constructor(uint256 _goal, uint256 _durationInDays) {\r\n owner = msg.sender;\r\n goal = _goal;\r\n deadline = block.timestamp + (_durationInDays * 1 days);\r\n }\r\n\r\n modifier onlyOwner() {\r\n require(msg.sender == owner, \"Not owner\");\r\n _;\r\n }\r\n\r\n function contribute() external payable {\r\n require(block.timestamp < deadline, \"Deadline passed\");\r\n require(msg.value > 0, \"No ETH sent\");\r\n contributions[msg.sender] += msg.value;\r\n totalRaised += msg.value;\r\n emit Contribution(msg.sender, msg.value);\r\n }\r\n\r\n function refund() external {\r\n require(block.timestamp >= deadline, \"Deadline not reached\");\r\n require(totalRaised < goal, \"Goal reached\");\r\n uint256 amount = contributions[msg.sender];\r\n require(amount > 0, \"Nothing to refund\");\r\n contributions[msg.sender] = 0;\r\n payable(msg.sender).transfer(amount);\r\n emit Refunded(msg.sender, amount);\r\n }\r\n\r\n function withdraw() external onlyOwner {\r\n require(block.timestamp >= deadline, \"Deadline not reached\");\r\n require(totalRaised >= goal, \"Goal not reached\");\r\n uint256 amount = address(this).balance;\r\n payable(owner).transfer(amount);\r\n emit Withdrawn(owner, amount);\r\n }\r\n}\r\n"}},"settings":{"optimizer":{"enabled":true,"runs":200},"outputSelection":{"*":{"":["ast"],"*":["abi","metadata","devdoc","userdoc","storageLayout","evm.legacyAssembly","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","evm.gasEstimates","evm.assembly"]}},"remappings":[],"evmVersion":"cancun"}}