Skip to content

Instantly share code, notes, and snippets.

@KBPsystem777
Created May 4, 2022 15:53
Show Gist options
  • Save KBPsystem777/382428f944e1386d7df56dee2d6a5a9f to your computer and use it in GitHub Desktop.
Save KBPsystem777/382428f944e1386d7df56dee2d6a5a9f to your computer and use it in GitHub Desktop.
EtherWallet - Accepts ethers and only owner can withdraw
// 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