Bounty.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. pragma solidity ^0.4.0;
  2. import './PullPayment.sol';
  3. /*
  4. * Bounty
  5. * This bounty will pay out if you can cause a SimpleToken's balance
  6. * to be lower than its totalSupply, which would mean that it doesn't
  7. * have sufficient ether for everyone to withdraw.
  8. */
  9. contract Factory {
  10. function deployContract() returns (address);
  11. }
  12. contract Target {
  13. function checkInvariant() returns(bool);
  14. }
  15. contract Bounty is PullPayment {
  16. Target target;
  17. bool public claimed;
  18. mapping(address => address) public researchers;
  19. function() {
  20. if (claimed) throw;
  21. }
  22. function createTarget(address factoryAddress) returns(Target) {
  23. target = Target(Factory(factoryAddress).deployContract());
  24. researchers[target] = msg.sender;
  25. return target;
  26. }
  27. function checkInvariant() returns(bool){
  28. return target.checkInvariant();
  29. }
  30. function claim(Target target) {
  31. address researcher = researchers[target];
  32. if (researcher == 0) throw;
  33. // Check Target contract invariants
  34. if (!target.checkInvariant()) {
  35. throw;
  36. }
  37. asyncSend(researcher, this.balance);
  38. claimed = true;
  39. }
  40. }