Skip to content

Instantly share code, notes, and snippets.

@micahriggan
Created October 27, 2018 00:14
Show Gist options
  • Save micahriggan/d57424f7da2fc72e3a6d28d2ac1bcc65 to your computer and use it in GitHub Desktop.
Save micahriggan/d57424f7da2fc72e3a6d28d2ac1bcc65 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.24;
contract SimpleContract {
uint public paymentCount = 0;
event PaymentReceived(uint value, address sender);
address public owner;
constructor() public {
owner = msg.sender;
}
function () public payable {
paymentCount += 1;
emit PaymentReceived(msg.value, msg.sender);
}
function balance() public view returns(uint) {
return address(this).balance;
}
modifier isOwner() {
require(msg.sender == owner, "Must be the owner");
_;
}
function withdraw() public isOwner {
owner.transfer(this.balance());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment