-
-
Save konradkonrad/cace570c26cc1873f379 to your computer and use it in GitHub Desktop.
Faucet Contract
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
contract Faucet { | |
address owner; | |
uint256 sendAmount; | |
mapping (address => uint) lastSent; | |
uint blockLimit; | |
function Faucet(){ | |
owner = msg.sender; | |
sendAmount = 1000000000000000000; | |
blockLimit = 5; | |
} | |
function getBalance() returns (uint){ | |
return address(this).balance; | |
} | |
function getWei() returns (bool){ | |
if(lastSent[msg.sender]<(block.number-blockLimit)&&address(this).balance>sendAmount){ | |
msg.sender.send(sendAmount); | |
lastSent[msg.sender] = block.number; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function sendWei(address recp) returns (bool){ | |
if(lastSent[msg.sender]<(block.number-blockLimit)&&address(this).balance>sendAmount){ | |
recp.send(sendAmount); | |
lastSent[msg.sender] = block.number; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function getRemainingBlocks() returns (uint){ | |
if(blockLimit>(block.number-lastSent[msg.sender])) | |
return blockLimit-(block.number-lastSent[msg.sender]); | |
else | |
return 0; | |
} | |
function getBlockLimit() returns (uint){ | |
return blockLimit; | |
} | |
function setBlockLimit(uint limit) returns (bool){ | |
if(msg.sender==owner) { | |
blockLimit = limit; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function setSendAmount(uint256 val) returns (bool){ | |
if(msg.sender==owner) { | |
sendAmount = val; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function getSendAmount() returns (uint256){ | |
return sendAmount; | |
} | |
function killMe(){ | |
if(msg.sender==owner) { | |
suicide(owner); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment