Last active
August 3, 2022 17:17
-
-
Save developeruche/f55b6c788424b1be1cc02da24e9edaaa to your computer and use it in GitHub Desktop.
This file contains 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 YouDeposit { | |
mapping(address => uint) balances; | |
function deposit() public payable { | |
require(msg.value > 0, "No value sent"); | |
balances[msg.sender] += msg.value; | |
} | |
function userBalance(address _user) external view returns(uint) { | |
return balances[_user]; | |
} | |
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