Skip to content

Instantly share code, notes, and snippets.

@casweeney
Created August 30, 2022 00:33
Show Gist options
  • Select an option

  • Save casweeney/7fad7c9d66b95242a6d1ba111c80cf56 to your computer and use it in GitHub Desktop.

Select an option

Save casweeney/7fad7c9d66b95242a6d1ba111c80cf56 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract EthereumWallet {
address owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "requires only owner");
_;
}
function deposit() external payable {
require(msg.value > 0, "can't send zero value");
}
function withdraw(uint _amount) external onlyOwner {
require(address(this).balance >= _amount, "insufficient fund");
payable(msg.sender).transfer(_amount);
}
function getWalletBalance() external view returns (uint bal) {
bal = address(this).balance;
}
receive() external payable {}
fallback() external payable {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment