SimpleTokenBounty.sol 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 SimpleTokenBounty is PullPayment {
  16. Target target;
  17. bool public claimed;
  18. address public factoryAddress;
  19. mapping(address => address) public researchers;
  20. function() {
  21. if (claimed) throw;
  22. }
  23. function SimpleTokenBounty(address _factoryAddress){
  24. factoryAddress = _factoryAddress;
  25. }
  26. function createTarget() returns(Target) {
  27. target = Target(Factory(factoryAddress).deployContract());
  28. researchers[target] = msg.sender;
  29. return target;
  30. }
  31. function checkInvariant() returns(bool){
  32. return target.checkInvariant();
  33. }
  34. function claim(Target target) {
  35. address researcher = researchers[target];
  36. if (researcher == 0) throw;
  37. // Check Target contract invariants
  38. if (!target.checkInvariant()) {
  39. throw;
  40. }
  41. asyncSend(researcher, this.balance);
  42. claimed = true;
  43. }
  44. }