Bounty.sol 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. pragma solidity ^0.4.4;
  2. import './PullPayment.sol';
  3. import './Killable.sol';
  4. /*
  5. * Bounty
  6. *
  7. * This bounty will pay out to a researcher if they break invariant logic of the contract.
  8. */
  9. contract Bounty is PullPayment, Killable {
  10. Target target;
  11. bool public claimed;
  12. mapping(address => address) public researchers;
  13. event TargetCreated(address createdAddress);
  14. function() payable {
  15. if (claimed) throw;
  16. }
  17. function createTarget() returns(Target) {
  18. target = Target(deployContract());
  19. researchers[target] = msg.sender;
  20. TargetCreated(target);
  21. return target;
  22. }
  23. function deployContract() internal returns(address);
  24. function checkInvariant() returns(bool){
  25. return target.checkInvariant();
  26. }
  27. function claim(Target target) {
  28. address researcher = researchers[target];
  29. if (researcher == 0) throw;
  30. // Check Target contract invariants
  31. if (target.checkInvariant()) {
  32. throw;
  33. }
  34. asyncSend(researcher, this.balance);
  35. claimed = true;
  36. }
  37. }
  38. contract Target {
  39. function checkInvariant() returns(bool);
  40. }