Created
February 26, 2018 16:47
-
-
Save AbstractFruitFactory/7e07eb9737661ead51d01f0e8d750013 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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