Created
April 1, 2020 16:46
-
-
Save xrzhuang/7ca712726ad1ff56298c8f833b88854a to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.26+commit.4563c3fc.js&optimize=false&gist=
This file contains 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
pragma solidity ^0.4.18; | |
contract EcoBtn { | |
address private latestAddress; | |
uint256 private latestBlock = 0; | |
uint private amount = 0; | |
uint public FIXED_AMOUNT_WEI = 1000000000000000000; | |
constructor() public { | |
latestBlock = block.number; | |
latestAddress = msg.sender; | |
} | |
function claimTreasure() public{ | |
require(block.number - latestBlock >= 3); | |
require(msg.sender == latestAddress); | |
msg.sender.transfer(address(this).balance); | |
amount = 0; | |
} | |
function pressBtn() public payable{ | |
require(msg.value >= FIXED_AMOUNT_WEI); | |
msg.sender.transfer(msg.value-FIXED_AMOUNT_WEI); | |
amount++; | |
latestBlock = block.number; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment