Skip to content

Instantly share code, notes, and snippets.

@developeruche
Last active August 3, 2022 17:17
Show Gist options
  • Save developeruche/f55b6c788424b1be1cc02da24e9edaaa to your computer and use it in GitHub Desktop.
Save developeruche/f55b6c788424b1be1cc02da24e9edaaa to your computer and use it in GitHub Desktop.
// 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