mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openzeppelin-contracts/contracts/Bounty.sol

63 lines
1.3 KiB

8 years ago
pragma solidity ^0.4.4;
import './PullPayment.sol';
import './Killable.sol';
/*
* Bounty
* This bounty will pay out to a researcher if he/she breaks invariant logic of
* the contract you bet reward against.
*/
contract Factory {
function deployContract() returns (address);
}
contract Target {
8 years ago
function checkInvariant() returns(bool);
}
contract Bounty is PullPayment, Killable {
Target target;
bool public claimed;
address public factoryAddress;
mapping(address => address) public researchers;
event TargetCreated(address createdAddress);
function() payable {
if (claimed) throw;
}
modifier withAddress(address _address) {
if(_address == 0) throw;
_;
}
function Bounty(address _factoryAddress) withAddress(_factoryAddress){
factoryAddress = _factoryAddress;
}
function createTarget() returns(Target) {
target = Target(Factory(factoryAddress).deployContract());
researchers[target] = msg.sender;
TargetCreated(target);
return target;
}
8 years ago
function checkInvariant() returns(bool){
return target.checkInvariant();
}
function claim(Target target) {
address researcher = researchers[target];
if (researcher == 0) throw;
// Check Target contract invariants
if (target.checkInvariant()) {
throw;
}
asyncSend(researcher, this.balance);
claimed = true;
}
}