Created
April 1, 2020 16:46
-
-
Save xrzhuang/7ca712726ad1ff56298c8f833b88854a to your computer and use it in GitHub Desktop.
Revisions
-
xrzhuang created this gist
Apr 1, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ 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; } }