From 857e37e03221f483ca4adef1fb8cca9d157795d2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 11 Aug 2016 16:29:10 -0300 Subject: [PATCH] Bounty contract --- contracts/Bounty.sol | 41 ++++++++++++++++++++++++++++++++ migrations/2_deploy_contracts.js | 1 + 2 files changed, 42 insertions(+) create mode 100644 contracts/Bounty.sol diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol new file mode 100644 index 000000000..ad7a765f3 --- /dev/null +++ b/contracts/Bounty.sol @@ -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; + } + +} diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 02476c063..1cb418de3 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -3,4 +3,5 @@ module.exports = function(deployer) { deployer.deploy(GoodFailEarly); deployer.deploy(PullPaymentBid); deployer.deploy(BadArrayUse); + deployer.deploy(Bounty); };