Created
May 4, 2022 15:53
-
-
Save KBPsystem777/382428f944e1386d7df56dee2d6a5a9f to your computer and use it in GitHub Desktop.
EtherWallet - Accepts ethers and only owner can withdraw
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.10; | |
/*** | |
* @title EtherWallet | |
* @author Koleen Baes Paunon | |
* @dev This contract accepts ether like a bank and users can withdraw thier ethers | |
*/ | |
contract EtherWallet { | |
address payable public owner; | |
constructor() { | |
owner = payable(msg.sender); | |
} | |
receive() external payable {} | |
function withdraw(uint _amount) external { | |
require(msg.sender == owner, "caller is not owner"); | |
payable(msg.sender).transfer(_amount); | |
} | |
function getBalance() external view returns (uint) { | |
return address(this).balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment