Last active
August 3, 2022 17:17
-
-
Save OdionOseiwe/a26d67bda5c900acd371039ed35000e1 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: GPL-3.0 | |
| // Write a simple contract that deposit fund into a contract. And also keep track of funds transferred into the contract. | |
| // Add a function to the balance of address that have deposited into the contract.(Submit Github gist) | |
| // 20 points | |
| pragma solidity >=0.7.0 <0.9.0; | |
| contract funds { | |
| mapping(address => uint) balances; | |
| uint timeReached; | |
| event events(address sender, uint balance); | |
| function stake() public payable { | |
| uint timeForCount = block.timestamp + 5 minutes; | |
| timeReached = timeForCount; | |
| require(msg.value > 0, 'no amount available'); | |
| balances[msg.sender] += msg.value; | |
| emit events(msg.sender, msg.value); | |
| } | |
| function returnBalance(address adds) external returns(uint){ | |
| return balances[adds] | |
| } | |
| function contractBalance() public view returns(uint256){ | |
| return address(this).balance; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment