Created
August 11, 2022 04:36
-
-
Save OdionOseiwe/eb888e079d15145858f9cf4af63b89be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.7; | |
| contract pause{ | |
| mapping(address => uint) public balances; | |
| mapping(address => uint) public NofDeposit; | |
| address[] allDespositors; | |
| function desposit() external payable{ | |
| require(msg.value == 1 ether, "must equal to 1 ether"); | |
| balances[msg.sender] += msg.value; | |
| if(balances[msg.sender] < 0) { | |
| allDespositors.push(msg.sender); | |
| } | |
| NofDeposit[msg.sender]++; | |
| } | |
| function borrow() external{ | |
| for(uint i = 0 ; i < allDespositors.length; i++){ | |
| require(msg.sender == allDespositors[i], "not a member"); | |
| } // use balance mapping | |
| require(NofDeposit[msg.sender] == 10, "not consi"); | |
| uint amountToBorrow = calucalatePauseBal(); | |
| (bool send,) = payable(msg.sender).call{value : amountToBorrow}(""); | |
| require(send, "failed"); | |
| } | |
| function pauseBal() external view returns(uint){ | |
| return address(this).balance; | |
| } | |
| function calucalatePauseBal() internal view returns(uint){ | |
| uint bal = address(this).balance; | |
| return (bal *80) / 100; | |
| } | |
| } | |
| /////////////////////////////////////////////////////////////////////// | |
| contract createMorePause{ | |
| pause[] public allContracts; | |
| function newOnes() external {crecreateMorePauseateMorePause | |
| allContracts.push(new pause()); | |
| } | |
| function returnPurse() public view returns(pause[] memory) { | |
| return allContracts; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment