Untitled diff

Created Diff never expires
/*
/*
This file is part of the DAO.
This file is part of the DAO.


The DAO is free software: you can redistribute it and/or modify
The DAO is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.


The DAO is distributed in the hope that it will be useful,
The DAO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU lesser General Public License for more details.
GNU lesser General Public License for more details.


You should have received a copy of the GNU lesser General Public License
You should have received a copy of the GNU lesser General Public License
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
*/
*/




/*
/*
Standard smart contract for a Decentralized Autonomous Organization (DAO)
Standard smart contract for a Decentralized Autonomous Organization (DAO)
to automate organizational governance and decision-making.
to automate organizational governance and decision-making.
*/
*/


/*
/*
This file is part of the DAO.
This file is part of the DAO.


The DAO is free software: you can redistribute it and/or modify
The DAO is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.


The DAO is distributed in the hope that it will be useful,
The DAO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU lesser General Public License for more details.
GNU lesser General Public License for more details.


You should have received a copy of the GNU lesser General Public License
You should have received a copy of the GNU lesser General Public License
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
*/
*/




/*
/*
Basic account, used by the DAO contract to separately manage both the rewards
Basic account, used by the DAO contract to separately manage both the rewards
and the extraBalance accounts.
and the extraBalance accounts.
*/
*/


contract ManagedAccountInterface {
contract ManagedAccountInterface {
// The only address with permission to withdraw from this account
// The only address with permission to withdraw from this account
address public owner;
address public owner;
// If true, only the owner of the account can receive ether from it
// If true, only the owner of the account can receive ether from it
bool public payOwnerOnly;
bool public payOwnerOnly;
// The sum of ether (in wei) which has been sent to this contract
// The sum of ether (in wei) which has been sent to this contract
uint public accumulatedInput;
uint public accumulatedInput;


/// @notice Sends `_amount` of wei to _recipient
/// @notice Sends `_amount` of wei to _recipient
/// @param _amount The amount of wei to send to `_recipient`
/// @param _amount The amount of wei to send to `_recipient`
/// @param _recipient The address to receive `_amount` of wei
/// @param _recipient The address to receive `_amount` of wei
/// @return True if the send completed
/// @return True if the send completed
function payOut(address _recipient, uint _amount) returns (bool);
function payOut(address _recipient, uint _amount) returns (bool);


event PayOut(address indexed _recipient, uint _amount);
event PayOut(address indexed _recipient, uint _amount);
}
}




contract ManagedAccount is ManagedAccountInterface{
contract ManagedAccount is ManagedAccountInterface{


// The constructor sets the owner of the account
// The constructor sets the owner of the account
function ManagedAccount(address _owner, bool _payOwnerOnly) {
function ManagedAccount(address _owner, bool _payOwnerOnly) {
owner = _owner;
owner = _owner;
payOwnerOnly = _payOwnerOnly;
payOwnerOnly = _payOwnerOnly;
}
}


// When the contract receives a transaction without data this is called.
// When the contract receives a transaction without data this is called.
// It counts the amount of ether it receives and stores it in
// It counts the amount of ether it receives and stores it in
// accumulatedInput.
// accumulatedInput.
function() {
function() {
accumulatedInput += msg.value;
accumulatedInput += msg.value;
}
}


function payOut(address _recipient, uint _amount) returns (bool) {
function payOut(address _recipient, uint _amount) returns (bool) {
if (msg.sender != owner || msg.value > 0 || (payOwnerOnly && _recipient != owner))
if (msg.sender != owner || msg.value > 0 || (payOwnerOnly && _recipient != owner))
throw;
throw;
if (_recipient.call.value(_amount)()) {
if (_recipient.call.value(_amount)()) {
PayOut(_recipient, _amount);
PayOut(_recipient, _amount);
return true;
return true;
} else {
} else {
return false;
return false;
}
}
}
}
}
}


/*
/*
This file is part of the DAO.
This file is part of the DAO.


The DAO is free software: you can redistribute it and/or modify
The DAO is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.


The DAO is distributed in the hope that it will be useful,
The DAO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU lesser General Public License for more details.
GNU lesser General Public License for more details.


You should have received a copy of the GNU lesser General Public License
You should have received a copy of the GNU lesser General Public License
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
*/
*/




/*
/*
* Token Creation contract, used by the DAO to create its tokens and initialize
* Token Creation contract, used by the DAO to create its tokens and initialize
* its ether. Feel free to modify the divisor method to implement different
* its ether. Feel free to modify the divisor method to implement different
* Token Creation parameters
* Token Creation parameters
*/
*/




/*
/*

- Bytecode Verification performed was compared on second iteration -

This file is part of the DAO.
This file is part of the DAO.


The DAO is free software: you can redistribute it and/or modify
The DAO is free software: you can redistribute it and/or modify
it under the terms of the GNU lesser General Public License as published by
it under the terms of the GNU lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.


The DAO is distributed in the hope that it will be useful,
The DAO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU lesser General Public License for more details.
GNU lesser General Public License for more details.


You should have received a copy of the GNU lesser General Public License
You should have received a copy of the GNU lesser General Public License
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
along with the DAO. If not, see <http://www.gnu.org/licenses/>.
*/
*/




/*
/*
Basic, standardized Token contract with no "premine". Defines the functions to
Basic, standardized Token contract with no "premine". Defines the functions to
check token balances, send tokens, send tokens on behalf of a 3rd party and the
check token balances, send tokens, send tokens on behalf of a 3rd party and the
corresponding approval process. Tokens need to be created by a derived
corresponding approval process. Tokens need to be created by a derived
contract (e.g. TokenCreation.sol).
contract (e.g. TokenCreation.sol).


Thank you ConsenSys, this contract originated from:
Thank you ConsenSys, this contract originated from:
https://github.com/ConsenSys/Tokens/blob/master/Token_Contracts/contracts/Standard_Token.sol
https://github.com/ConsenSys/Tokens/blob/master/Token_Contracts/contracts/Standard_Token.sol
Which is itself based on the Ethereum standardized contract APIs:
Which is itself based on the Ethereum standardized contract APIs:
https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs
https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs
*/
*/


/// @title Standard Token Contract.
/// @title Standard Token Contract.


contract TokenInterface {
contract TokenInterface {
mapping (address => uint256) balances;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => mapping (address => uint256)) allowed;


/// Total amount of tokens
/// Total amount of tokens
uint256 public totalSupply;
uint256 public totalSupply;


/// @param _owner The address from which the balance will be retrieved
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance);
function balanceOf(address _owner) constant returns (uint256 balance);


/// @notice Send `_amount` tokens to `_to` from `msg.sender`
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @param _amount The amount of tokens to be transferred
/// @return Whether the transfer was successful or not
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _amount) returns (bool success);
function transfer(address _to, uint256 _amount) returns (bool success);


/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
/// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
/// is approved by `_from`
/// is approved by `_from`
/// @param _from The address of the origin of the transfer
/// @param _from The address of the origin of the transfer
/// @param _to The address of the recipient
/// @param _to The address of the recipient
/// @param _amount The amount of tokens to be transferred
/// @param _amount The amount of tokens to be transferred
/// @return Whether the transfer was successful or not
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _amount) returns (bool success);
function transferFrom(address _from, address _to, uint256 _amount) returns (bool success);


/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
/// its behalf
/// its behalf
/// @param _spender The address of the account able to transfer the tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @param _amount The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _amount) returns (bool success);
function approve(address _spender, uint256 _amount) returns (bool success);


/// @param _owner The address of the account owning tokens
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens of _owner that _spender is allowed
/// @return Amount of remaining tokens of _owner that _spender is allowed
/// to spend
/// to spend
function allowance(
function allowance(
address _owner,
address _owner,
address _spender
address _spender
) constant returns (uint256 remaining);
) constant returns (uint256 remaining);


event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event Approval(
event Approval(
address indexed _owner,
address indexed _owner,
address indexed _spender,
address indexed _spender,
uint256 _amount
uint256 _amount
);
);
}
}




contract Token is TokenInterface {
contract Token is TokenInterface {
// Protects users by preventing the execution of method calls that
// Protects users by preventing the execution of method calls that
// inadvertently also transferred ether
// inadvertently also transferred ether
modifier noEther() {if (msg.value > 0) throw; _}
modifier noEther() {if (msg.value > 0) throw; _}


function balanceOf(address _owner) constant returns (uint256 balance) {
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
return balances[_owner];
}
}


function transfer(address _to, uint256 _amount) noEther returns (bool success) {
function transfer(address _to, uint256 _amount) noEther returns (bool success) {
if (balances[msg.sender] >= _amount && _amount > 0) {
if (balances[msg.sender] >= _amount && _amount > 0) {
balances[msg.sender] -= _amount;
balances[msg.sender] -= _amount;
balances[_to] += _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
Transfer(msg.sender, _to, _amount);
return true;
return true;
} else {
} else {
return false;
return false;
}
}
}
}


function transferFrom(
function transferFrom(
address _from,
address _from,
address _to,
address _to,
uint256 _amount
uint256 _amount
) noEther returns (bool success) {
) noEther returns (bool success) {


if (balances[_from] >= _amount
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0) {
&& _amount > 0) {


balances[_to] += _amount;
balances[_to] += _amount;
balances[_from] -= _amount;
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
allowed[_from][msg.sender] -= _amount;
Transfer(_from, _to, _amount);
Transfer(_from, _to, _amount);
return true;
return true;
} else {
} else {
return false;
return false;
}
}
}
}


function approve(address _spender, uint256 _amount) returns (bool success) {
function approve(address _spender, uint256 _amount) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
Approval(msg.sender, _spender, _amount);
return true;
return true;
}
}


function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
return allowed[_owner][_spender];
}
}
}
}




contract TokenCreationInterface {
contract TokenCreationInterface {


// End of token creation, in Unix time
// End of token creation, in Unix time
uint public closingTime;
uint public closingTime;
// Minimum fueling goal of the token creation, denominated in tokens to
// Minimum fueling goal of the token creation, denominated in tokens to
// be created
// be created
uint public minTokensToCreate;
uint public minTokensToCreate;
// True if the DAO reached its minimum fueling goal, false otherwise
// True if the DAO reached its minimum fueling goal, false otherwise
bool public isFueled;
bool public isFueled;
// For DAO splits - if privateCreation is 0, then it is a public token
// For DAO splits - if privateCreation is 0, then it is a public token
// creation, otherwise only the address stored in privateCreation is
// creation, otherwise only the address stored in privateCreation is
// allowed to create tokens
// allowed to create tokens
address public privateCreation;
address public privateCreation;
// hold extra ether which has been sent after the DAO token
// hold extra ether which has been sent after the DAO token
// creation rate has increased
// creation rate has increased
ManagedAccount public extraBalance;
ManagedAccount public extraBalance;
// tracks the amount of wei given from each contributor (used for refund)
// tracks the amount of wei given from each contributor (used for refund)
mapping (address => uint256) weiGiven;
mapping (address => uint256) weiGiven;


/// @dev Constructor setting the minimum fueling goal and the
/// @dev Constructor setting the minimum fueling goal and the
/// end of the Token Creation
/// end of the Token Creation
/// @param _minTokensToCreate Minimum fueling goal in number of
/// @param _minTokensToCreate Minimum fueling goal in number of
/// Tokens to be created
/// Tokens to be created
/// @param _closingTime Date (in Unix time) of the end of the Token Creation
/// @param _closingTime Date (in Unix time) of the end of the Token Creation
/// @param _privateCreation Zero means that the creation is public. A
/// @param _privateCreation Zero means that the creation is public. A
/// non-zero address represents the only address that can create Tokens
/// non-zero address represents the only address that can create Tokens
/// (the address can also create Tokens on behalf of other accounts)
/// (the address can also create Tokens on behalf of other accounts)
// This is the constructor: it can not be overloaded so it is commented out
// This is the constructor: it can not be overloaded so it is commented out
// function TokenCreation(
// function TokenCreation(
// uint _minTokensTocreate,
// uint _minTokensTocreate,
// uint _closingTime,
// uint _closingTime,
// address _privateCreation
// address _privateCreation
// );
// );


/// @notice Create Token with `_tokenHolder` as the initial owner of the Token
/// @notice Create Token with `_tokenHolder` as the initial owner of the Token
/// @param _tokenHolder The address of the Tokens's recipient
/// @param _tokenHolder The address of the Tokens's recipient
/// @return Whether the token creation was successful
/// @return Whether the token creation was successful
function createTokenProxy(address _tokenHolder) returns (bool success);
function createTokenProxy(address _tokenHolder) returns (bool success);


/// @notice Refund `msg.sender` in the case the Token Creation did
/// @notice Refund `msg.sender` in the case the Token Creation did
/// not reach its minimum fueling goal
/// not reach its minimum fueling goal
function refund();
function refund();


/// @return The divisor used to calculate the token creation rate during
/// @return The divisor used to calculate the token creation rate during
/// the creation phase
/// the creation phase
function divisor() constant returns (uint divisor);
function divisor() constant returns (uint divisor);


event FuelingToDate(uint value);
event FuelingToDate(uint value);
event CreatedToken(address indexed to, uint amount);
event CreatedToken(address indexed to, uint amount);
event Refund(address indexed to, uint value);
event Refund(address indexed to, uint value);
}
}




contract TokenCreation is TokenCreationInterface, Token {
contract TokenCreation is TokenCreationInterface, Token {
function TokenCreation(
function TokenCreation(
uint _minTokensToCreate,
uint _minTokensToCreate,
uint _closingTime,
uint _closingTime,
address _privateCreation) {
address _privateCreation) {


closingTime = _closingTime;
closingTime = _closingTime;
minTokensToCreate = _minTokensToCreate;
minTokensToCreate = _minTokensToCreate;
privateCreation = _privateCreation;
privateCreation = _privateCreation;
extraBalance = new ManagedAccount(address(this), true);
extraBalance = new ManagedAccount(address(this), true);
}
}


function createTokenProxy(address _tokenHolder) returns (bool success) {
function createTokenProxy(address _tokenHolder) returns (bool success) {
if (now < closingTime && msg.value > 0
if (now < closingTime && msg.value > 0
&& (privateCreation == 0 || privateCreation == msg.sender)) {
&& (privateCreation == 0 || privateCreation == msg.sender)) {


uint token = (msg.value * 20) / divisor();
uint token = (msg.value * 20) / divisor();
extraBalance.call.value(msg.value - token)();
extraBalance.call.value(msg.value - token)();
balances[_tokenHolder] += token;
balances[_tokenHolder] += token;
totalSupply += token;
totalSupply += token;
weiGiven[_tokenHolder] += msg.value;
weiGiven[_tokenHolder] += msg.value;
CreatedToken(_tokenHolder, token);
CreatedToken(_tokenHolder, token);
if (totalSupply >= minTokensToCreate && !isFueled) {
if (totalSupply >= minTokensToCreate && !isFueled) {
isFueled = true;
isFueled = true;
FuelingToDate(totalSupply);
FuelingToDate(totalSupply);
}
}
return true;
return true;
}
}
throw;
throw;
}
}


function refund() noEther {
function refund() noEther {
if (now > closingTime && !isFueled) {
if (now > closingTime && !isFueled) {
// Get extraBalance - will only succeed when called for the first time
// Get extraBalance - will only succeed when called for the first time
if (extraBalance.balance >= extraBalance.accumulatedInput())
if (extraBalance.balance >= extraBalance.accumulatedInput())
extraBalance.payOut(address(this), extraBalance.accumulatedInput());
extraBalance.payOut(address(this), extraBalance.accumulatedInput());


// Execute refund
// Execute refund
if (msg.sender.call.value(weiGiven[msg.sender])()) {
if (msg.sender.call.value(weiGiven[msg.sender])()) {
Refund(msg.sender, weiGiven[msg.sender]);
Refund(msg.sender, weiGiven[msg.sender]);
totalSupply -= balances[msg.sender];
totalSupply -= balances[msg.sender];
balances[msg.sender] = 0;
balances[msg.sender] = 0;
weiGiven[msg.sender] = 0;
weiGiven[msg.sender] = 0;
}
}
}
}
}
}


function divisor() constant returns (uint divisor) {
function divisor() constant returns (uint divisor) {
// The number of (base unit) tokens per wei is calculated
// as `msg.value` * 20 / `divisor`
// The fueling period starts with a 1:1 ratio
if (closingTime - 2 weeks > now) {
return 20;
return 20;
// Followed by 10 days with a daily creation rate increase of 5%
} else if (closingTime - 4 days > now) {
return (20 + (now - (closingTime - 2 weeks)) / (1 days));
// The last 4 days there is a constant creation rate ratio of 1:1.5
} else {
return 30;
}
}
}
}
}




contract DAOInterface {
contract DAOInterface {


// The amount of days for which people who try to participate in the
// The amount of days for which people who try to participate in the
// creation by calling the fallback function will still get their ether back
// creation by calling the fallback function will still get their ether back
uint constant creationGracePeriod = 40 days;
uint constant creationGracePeriod = 40 days;
// The minimum debate period that a generic proposal can have
// The minimum debate period that a generic proposal can have
uint constant minProposalDebatePeriod = 2 weeks;
uint constant minProposalDebatePeriod = 3 days;
// The minimum debate period that a split proposal can have
// The minimum debate period that a split proposal can have
uint constant minSplitDebatePeriod = 1 weeks;
uint constant minSplitDebatePeriod = 0 days;
// Period of days inside which it's possible to execute a DAO split
// Period of days inside which it's possible to execute a DAO split
uint constant splitExecutionPeriod = 27 days;
uint constant splitExecutionPeriod = 1 days;
// Period of time after which the minimum Quorum is halved
// Period of time after which the minimum Quorum is halved
uint constant quorumHalvingPeriod = 25 weeks;
uint constant quorumHalvingPeriod = 2 weeks;
// Period after which a proposal is closed
// Period after which a proposal is closed
// (used in the case `executeProposal` fails because it throws)
// (used in the case `executeProposal` fails because it throws)
uint constant executeProposalPeriod = 10 days;
uint constant executeProposalPeriod = 2 days;
// Denotes the maximum proposal deposit that can be given. It is given as
// Denotes the maximum proposal deposit that can be given. It is given as
// a fraction of total Ether spent plus balance of the DAO
// a fraction of total Ether spent plus balance of the DAO
uint constant maxDepositDivisor = 100;
uint constant maxDepositDivisor = 100;


// Proposals to spend the DAO's ether or to choose a new Curator
// Proposals to spend the DAO's ether or to choose a new Curator
Proposal[] public proposals;
Proposal[] public proposals;
// The quorum needed for each proposal is partially calculated by
// The quorum needed for each proposal is partially calculated by
// totalSupply / minQuorumDivisor
// totalSupply / minQuorumDivisor
uint public minQuorumDivisor;
uint public minQuorumDivisor;
// The unix time of the last time quorum was reached on a proposal
// The unix time of the last time quorum was reached on a proposal
uint public lastTimeMinQuorumMet;
uint public lastTimeMinQuorumMet;


// Address of the curator
// Address of the curator
address public curator;
address public curator;
// The whitelist: List of addresses the DAO is allowed to send ether to
// The whitelist: List of addresses the DAO is allowed to send ether to
mapping (address => bool) public allowedRecipients;
mapping (address => bool) public allowedRecipients;


// Tracks the addresses that own Reward Tokens. Those addresses can only be
// Tracks the addresses that own Reward Tokens. Those addresses can only be
// DAOs that have split from the original DAO. Conceptually, Reward Tokens
// DAOs that have split from the original DAO. Conceptually, Reward Tokens
// represent the proportion of the rewards that the DAO has the right to
// represent the proportion of the rewards that the DAO has the right to
// receive. These Reward Tokens are generated when the DAO spends ether.
// receive. These Reward Tokens are generated when the DAO spends ether.
mapping (address => uint) public rewardToken;
mapping (address => uint) public rewardToken;
// Total supply of rewardToken
// Total supply of rewardToken
uint public totalRewardToken;
uint public totalRewardToken;


// The account used to manage the rewards which are to be distributed to the
// The account used to manage the rewards which are to be distributed to the
// DAO Token Holders of this DAO
// DAO Token Holders of this DAO
ManagedAccount public rewardAccount;
ManagedAccount public rewardAccount;


// The account used to manage the rewards which are to be distributed to
// The account used to manage the rewards which are to be distributed to
// any DAO that holds Reward Tokens
// any DAO that holds Reward Tokens
ManagedAccount public DAOrewardAccount;
ManagedAccount public DAOrewardAccount;


// Amount of rewards (in wei) already paid out to a certain DAO
// Amount of rewards (in wei) already paid out to a certain DAO
mapping (address => uint) public DAOpaidOut;
mapping (address => uint) public DAOpaidOut;


// Amount of rewards (in wei) already paid out to a certain address
// Amount of rewards (in wei) already paid out to a certain address
mapping (address => uint) public paidOut;
mapping (address => uint) public paidOut;
// Map of addresses blocked during a vote (not allowed to transfer DAO
// Map of addresses blocked during a vote (not allowed to transfer DAO
// tokens). The address points to the proposal ID.
// tokens). The address points to the proposal ID.
mapping (address => uint) public blocked;
mapping (address => uint) public blocked;


// The minimum deposit (in wei) required to submit any proposal that is not
// The minimum deposit (in wei) required to submit any proposal that is not
// requesting a new Curator (no deposit is required for splits)
// requesting a new Curator (no deposit is required for splits)
uint public proposalDeposit;
uint public proposalDeposit;


// the accumulated sum of all current proposal deposits
// the accumulated sum of all current proposal deposits
uint sumOfProposalDeposits;
uint sumOfProposalDeposits;


// Contract that is able to create a new DAO (with the same code as
// Contract that is able to create a new DAO (with the same code as
// this one), used for splits
// this one), used for splits
DAO_Creator public daoCreator;
DAO_Creator public daoCreator;


// A proposal with `newCurator == false` represents a transaction
// A proposal with `newCurator == false` represents a transaction
// to be issued by this DAO
// to be issued by this DAO
// A proposal with `newCurator == true` represents a DAO split
// A proposal with `newCurator == true` represents a DAO split
struct Proposal {
struct Proposal {
// The address where the `amount` will go to if the proposal is accepted
// The address where the `amount` will go to if the proposal is accepted
// or if `newCurator` is true, the proposed Curator of
// or if `newCurator` is true, the proposed Curator of
// the new DAO).
// the new DAO).
address recipient;
address recipient;
// The amount to transfer to `recipient` if the proposal is accepted.
// The amount to transfer to `recipient` if the proposal is accepted.
uint amount;
uint amount;
// A plain text description of the proposal
// A plain text description of the proposal
string description;
string description;
// A unix timestamp, denoting the end of the voting period
// A unix timestamp, denoting the end of the voting period
uint votingDeadline;
uint votingDeadline;
// True if the proposal's votes have yet to be counted, otherwise False
// True if the proposal's votes have yet to be counted, otherwise False
bool open;
bool open;
// True if quorum has been reached, the votes have been counted, and
// True if quorum has been reached, the votes have been counted, and
// the majority said yes
// the majority said yes
bool proposalPassed;
bool proposalPassed;
// A hash to check validity of a proposal
// A hash to check validity of a proposal
bytes32 proposalHash;
bytes32 proposalHash;
// Deposit in wei the creator added when submitting their proposal. It
// Deposit in wei the creator added when submitting their proposal. It
// is taken from the msg.value of a newProposal call.
// is taken from the msg.value of a newProposal call.
uint proposalDeposit;
uint proposalDeposit;
// True if this proposal is to assign a new Curator
// True if this proposal is to assign a new Curator
bool newCurator;
bool newCurator;
// Data needed for splitting the DAO
// Data needed for splitting the DAO
SplitData[] splitData;
SplitData[] splitData;
// Number of Tokens in favor of the proposal
// Number of Tokens in favor of the proposal
uint yea;
uint yea;
// Number of Tokens opposed to the proposal
// Number of Tokens opposed to the proposal
uint nay;
uint nay;
// Simple mapping to check if a shareholder has voted for it
// Simple mapping to check if a shareholder has voted for it
mapping (address => bool) votedYes;
mapping (address => bool) votedYes;
// Simple mapping to check if a shareholder has voted against it
// Simple mapping to check if a shareholder has voted against it
mapping (address => bool) votedNo;
mapping (address => bool) votedNo;
// Address of the shareholder who created the proposal
// Address of the shareholder who created the proposal
address creator;
address creator;
}
}


// Used only in the case of a newCurator proposal.
// Used only in the case of a newCurator proposal.
struct SplitData {
struct SplitData {
// The balance of the current DAO minus the deposit at the time of split
// The balance of the current DAO minus the deposit at the time of split
uint splitBalance;
uint splitBalance;
// The total amount of DAO Tokens in existence at the time of split.
// The total amount of DAO Tokens in existence at the time of split.
uint totalSupply;
uint totalSupply;
// Amount of Reward Tokens owned by the DAO at the time of split.
// Amount of Reward Tokens owned by the DAO at the time of split.
uint rewardToken;
uint rewardToken;
// The new DAO contract created at the time of split.
// The new DAO contract created at the time of split.
DAO newDAO;
MICRODAO newDAO;
}
}


// Used to restrict access to certain functions to only DAO Token Holders
// Used to restrict access to certain functions to only DAO Token Holders
modifier onlyTokenholders {}
modifier onlyTokenholders {}


/// @dev Constructor setting the Curator and the address
/// @dev Constructor setting the Curator and the address
/// for the contract able to create another DAO as well as the parameters
/// for the contract able to create another DAO as well as the parameters
/// for the DAO Token Creation
/// for the DAO Token Creation
/// @param _curator The Curator
/// @param _curator The Curator
/// @param _daoCreator The contract able to (re)create this DAO
/// @param _daoCreator The contract able to (re)create this DAO
/// @param _proposalDeposit The deposit to be paid for a regular proposal
/// @param _proposalDeposit The deposit to be paid for a regular proposal
/// @param _minTokensToCreate Minimum required wei-equivalent tokens
/// @param _minTokensToCreate Minimum required wei-equivalent tokens
/// to be created for a successful DAO Token Creation
/// to be created for a successful DAO Token Creation
/// @param _closingTime Date (in Unix time) of the end of the DAO Token Creation
/// @param _closingTime Date (in Unix time) of the end of the DAO Token Creation
/// @param _privateCreation If zero the DAO Token Creation is open to public, a
/// @param _privateCreation If zero the DAO Token Creation is open to public, a
/// non-zero address means that the DAO Token Creation is only for the address
/// non-zero address means that the DAO Token Creation is only for the address
// This is the constructor: it can not be overloaded so it is commented out
// This is the constructor: it can not be overloaded so it is commented out
// function DAO(
// function DAO(
// address _curator,
// address _curator,
// DAO_Creator _daoCreator,
// DAO_Creator _daoCreator,
// uint _proposalDeposit,
// uint _proposalDeposit,
// uint _minTokensToCreate,
// uint _minTokensToCreate,
// uint _closingTime,
// uint _closingTime,
// address _privateCreation
// addresses _privateCreation
// );
// );


/// @notice Create Token with `msg.sender` as the beneficiary
/// @notice Create Token with `msg.sender` as the beneficiary
/// @return Whether the token creation was successful
/// @return Whether the token creation was successful
function () returns (bool success);
function () returns (bool success);




/// @dev This function is used to send ether back
/// @dev This function is used to send ether back
/// to the DAO, it can also be used to receive payments that should not be
/// to the DAO, it can also be used to receive payments that should not be
/// counted as rewards (donations, grants, etc.)
/// counted as rewards (donations, grants, etc.)
/// @return Whether the DAO received the ether successfully
/// @return Whether the DAO received the ether successfully
function receiveEther() returns(bool);
function receiveEther() returns(bool);


/// @notice `msg.sender` creates a proposal to send `_amount` Wei to
/// @notice `msg.sender` creates a proposal to send `_amount` Wei to
/// `_recipient` with the transaction data `_transactionData`. If
/// `_recipient` with the transaction data `_transactionData`. If
/// `_newCurator` is true, then this is a proposal that splits the
/// `_newCurator` is true, then this is a proposal that splits the
/// DAO and sets `_recipient` as the new DAO's Curator.
/// DAO and sets `_recipient` as the new DAO's Curator.
/// @param _recipient Address of the recipient of the proposed transaction
/// @param _recipient Address of the recipient of the proposed transaction
/// @param _amount Amount of wei to be sent with the proposed transaction
/// @param _amount Amount of wei to be sent with the proposed transaction
/// @param _description String describing the proposal
/// @param _description String describing the proposal
/// @param _transactionData Data of the proposed transaction
/// @param _transactionData Data of the proposed transaction
/// @param _debatingPeriod Time used for debating a proposal, at least 2
/// @param _debatingPeriod Time used for debating a proposal, at least 2
/// weeks for a regular proposal, 10 days for new Curator proposal
/// weeks for a regular proposal, 10 days for new Curator proposal
/// @param _newCurator Bool defining whether this proposal is about
/// @param _newCurator Bool defining whether this proposal is about
/// a new Curator or not
/// a new Curator or not
/// @return The proposal ID. Needed for voting on the proposal
/// @return The proposal ID. Needed for voting on the proposal
function newProposal(
function newProposal(
address _recipient,
address _recipient,
uint _amount,
uint _amount,
string _description,
string _description,
bytes _transactionData,
bytes _transactionData,
uint _debatingPeriod,
uint _debatingPeriod,
bool _newCurator
bool _newCurator
) onlyTokenholders returns (uint _proposalID);
) onlyTokenholders returns (uint _proposalID);


/// @notice Check that the proposal with the ID `_proposalID` matches the
/// @notice Check that the proposal with the ID `_proposalID` matches the
/// transaction which sends `_amount` with data `_transactionData`
/// transaction which sends `_amount` with data `_transactionData`
/// to `_recipient`
/// to `_recipient`
/// @param _proposalID The proposal ID
/// @param _proposalID The proposal ID
/// @param _recipient The recipient of the proposed transaction
/// @param _recipient The recipient of the proposed transaction
/// @param _amount The amount of wei to be sent in the proposed transaction
/// @param _amount The amount of wei to be sent in the proposed transaction
/// @param _transactionData The data of the proposed transaction
/// @param _transactionData The data of the proposed transaction
/// @return Whether the proposal ID matches the transaction data or not
/// @return Whether the proposal ID matches the transaction data or not
function checkProposalCode(
function checkProposalCode(
uint _proposalID,
uint _proposalID,
address _recipient,
address _recipient,
uint _amount,
uint _amount,
bytes _transactionData
bytes _transactionData
) constant returns (bool _codeChecksOut);
) constant returns (bool _codeChecksOut);


/// @notice Vote on proposal `_proposalID` with `_supportsProposal`
/// @notice Vote on proposal `_proposalID` with `_supportsProposal`
/// @param _proposalID The proposal ID
/// @param _proposalID The proposal ID
/// @param _supportsProposal Yes/No - support of the proposal
/// @param _supportsProposal Yes/No - support of the proposal
/// @return The vote ID.
/// @return The vote ID.
function vote(
function vote(
uint _proposalID,
uint _proposalID,
bool _supportsProposal
bool _supportsProposal
) onlyTokenholders returns (uint _voteID);
) onlyTokenholders returns (uint _voteID);


/// @notice Checks whether proposal `_proposalID` with transaction data
/// @notice Checks whether proposal `_proposalID` with transaction data
/// `_transactionData` has been voted for or rejected, and executes the
/// `_transactionData` has been voted for or rejected, and executes the
/// transaction in the case it has been voted for.
/// transaction in the case it has been voted for.
/// @param _proposalID The proposal ID
/// @param _proposalID The proposal ID
/// @param _transactionData The data of the proposed transaction
/// @param _transactionData The data of the proposed transaction
/// @return Whether the proposed transaction has been executed or not
/// @return Whether the proposed transaction has been executed or not
function executeProposal(
function executeProposal(
uint _proposalID,
uint _proposalID,
bytes _transactionData
bytes _transactionData
) returns (bool _success);
) returns (bool _success);


/// @notice ATTENTION! I confirm to move my remaining ether to a new DAO
/// @notice ATTENTION! I confirm to move my remaining ether to a new DAO
/// with `_newCurator` as the new Curator, as has been
/// with `_newCurator` as the new Curator, as has been
/// proposed in proposal `_proposalID`. This will burn my tokens. This can
/// proposed in proposal `_proposalID`. This will burn my tokens. This can
/// not be undone and will split the DAO into two DAO's, with two
/// not be undone and will split the DAO into two DAO's, with two
/// different underlying tokens.
/// different underlying tokens.
/// @param _proposalID The proposal ID
/// @param _proposalID The proposal ID
/// @param _newCurator The new Curator of the new DAO
/// @param _newCurator The new Curator of the new DAO
/// @dev This function, when called for the first time for this proposal,
/// @dev This function, when called for the first time for this proposal,
/// will create a new DAO and send the sender's portion of the remaining
/// will create a new DAO and send the sender's portion of the remaining
/// ether and Reward Tokens to the new DAO. It will also burn the DAO Tokens
/// ether and Reward Tokens to the new DAO. It will also burn the DAO Tokens
/// of the sender.
/// of the sender.
function splitDAO(
function splitDAO(
uint _proposalID,
uint _proposalID,
address _newCurator
address _newCurator
) returns (bool _success);
) returns (bool _success);


/// @dev can only be called by the DAO itself through a proposal
/// @dev can only be called by the DAO itself through a proposal
/// updates the contract of the DAO by sending all ether and rewardTokens
/// updates the contract of the DAO by sending all ether and rewardTokens
/// to the new DAO. The new DAO needs to be approved by the Curator
/// to the new DAO. The new DAO needs to be approved by the Curator
/// @param _newContract the address of the new contract
/// @param _newContract the address of the new contract
function newContract(address _newContract);
function newContract(address _newContract);




/// @notice Add a new possible recipient `_recipient` to the whitelist so
/// @notice Add a new possible recipient `_recipient` to the whitelist so
/// that the DAO can send transactions to them (using proposals)
/// that the DAO can send transactions to them (using proposals)
/// @param _recipient New recipient address
/// @param _recipient New recipient address
/// @dev Can only be called by the current Curator
/// @dev Can only be called by the current Curator
/// @return Whether successful or not
/// @return Whether successful or not
function changeAllowedRecipients(address _recipient, bool _allowed) external returns (bool _success);
function changeAllowedRecipients(address _recipient, bool _allowed) external returns (bool _success);




/// @notice Change the minimum deposit required to submit a proposal
/// @notice Change the minimum deposit required to submit a proposal
/// @param _proposalDeposit The new proposal deposit
/// @param _proposalDeposit The new proposal deposit
/// @dev Can only be called by this DAO (through proposals with the
/// @dev Can only be called by this DAO (through proposals with the
/// recipient being this DAO itself)
/// recipient being this DAO itself)
function changeProposalDeposit(uint _proposalDeposit) external;

/// @notice Move rewards from the DAORewards managed account
/// @param _toMembers If true rewards are moved to the actual reward account
/// for the DAO. If not then it's moved to the DAO itself
/// @return Whether the call was successful
function retrieveDAOReward(bool _toMembers) external returns (bool _success);

/// @notice Get my portion of the reward that was sent to `rewardAccount`
/// @return Whether the call was successful
function getMyReward() returns(bool _succ