Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AbstractFruitFactory/7e07eb9737661ead51d01f0e8d750013 to your computer and use it in GitHub Desktop.
Save AbstractFruitFactory/7e07eb9737661ead51d01f0e8d750013 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.17;
import '../node_modules/zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';
import './IVotingMechanism.sol';
contract OutcomeBondToken is StandardToken {
string public name;
mapping (address => uint) private backerTokens;
address voting;
function OutcomeBondToken(string _name, address _votingAddress) public {
name = _name;
voting = _votingAddress;
}
function back() public payable {
require(msg.value > 0);
balances[msg.sender] += msg.value;
backerTokens[msg.sender] += msg.value;
}
function redeemBackerTokens(uint _value) public {
require(_value > 0);
require(backerTokens[msg.sender] >= _value);
IVotingMechanism votingContract = IVotingMechanism(voting);
require(votingContract.checkVote(this) == IVotingMechanism.Vote.NOT_MET);
backerTokens[msg.sender] -= _value;
msg.sender.transfer(_value);
}
function redeemRewardTokens(uint _value) public {
require(_value > 0);
require(balances[msg.sender] >= _value);
IVotingMechanism votingContract = IVotingMechanism(voting);
require(votingContract.checkVote(this) == IVotingMechanism.Vote.MET);
balances[msg.sender] -= _value;
msg.sender.transfer(_value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment