Bounty.sol 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. pragma solidity ^0.4.4;
  2. import './PullPayment.sol';
  3. import './Killable.sol';
  4. /*
  5. * Bounty
  6. * This bounty will pay out to a researcher if he/she breaks invariant logic of
  7. * the contract you bet reward against.
  8. */
  9. contract Target {
  10. function checkInvariant() returns(bool);
  11. }
  12. contract Bounty is PullPayment, Killable {
  13. Target target;
  14. bool public claimed;
  15. mapping(address => address) public researchers;
  16. event TargetCreated(address createdAddress);
  17. function() payable {
  18. if (claimed) throw;
  19. }
  20. function createTarget() returns(Target) {
  21. target = Target(deployContract());
  22. researchers[target] = msg.sender;
  23. TargetCreated(target);
  24. return target;
  25. }
  26. function deployContract() internal returns(address);
  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. }