Bounty contract
This commit is contained in:
41
contracts/Bounty.sol
Normal file
41
contracts/Bounty.sol
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import './PullPaymentCapable.sol';
|
||||||
|
import './Token.sol';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bounty
|
||||||
|
* This bounty will pay out if you can cause a Token's balance
|
||||||
|
* to be lower than its totalSupply, which would mean that it doesn't
|
||||||
|
* have sufficient ether for everyone to withdraw.
|
||||||
|
*/
|
||||||
|
|
||||||
|
contract Bounty is PullPaymentCapable {
|
||||||
|
|
||||||
|
bool public claimed;
|
||||||
|
mapping(address => address) public researchers;
|
||||||
|
|
||||||
|
function() {
|
||||||
|
if (claimed) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTarget() returns(Token) {
|
||||||
|
Token target = new Token(0);
|
||||||
|
researchers[target] = msg.sender;
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
function claim(Token target) {
|
||||||
|
address researcher = researchers[target];
|
||||||
|
if (researcher == 0) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
// check Token contract invariants
|
||||||
|
if (target.totalSupply() == target.balance) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
asyncSend(researcher, this.balance);
|
||||||
|
claimed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,4 +3,5 @@ module.exports = function(deployer) {
|
|||||||
deployer.deploy(GoodFailEarly);
|
deployer.deploy(GoodFailEarly);
|
||||||
deployer.deploy(PullPaymentBid);
|
deployer.deploy(PullPaymentBid);
|
||||||
deployer.deploy(BadArrayUse);
|
deployer.deploy(BadArrayUse);
|
||||||
|
deployer.deploy(Bounty);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user