Last active
August 4, 2022 16:58
-
-
Save casweeney/5965a21cc0a63561a6eb97fed0be8b6a to your computer and use it in GitHub Desktop.
This is the a second test at Web3Bridge Cohort VII
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.0; | |
| contract Deposit { | |
| mapping(address => uint) balances; | |
| function deposit() public payable { | |
| require(msg.value > 0, "No value sent"); | |
| balances[msg.sender] += msg.value; | |
| } | |
| function userBalance() external view returns(uint) { | |
| return balances[msg.sender]; | |
| } | |
| receive() external payable { | |
| deposit(); | |
| } | |
| function withdraw() public { | |
| require(balances[msg.sender] > 0, "No stake"); | |
| payable(msg.sender).transfer(balances[msg.sender]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment