Guest User

Untitled

a guest
Jan 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. pragma solidity ^0.4.19;
  2.  
  3. contract owned {
  4. address public owner;
  5.  
  6. function owned() {
  7. owner = msg.sender;
  8. }
  9.  
  10. modifier onlyOwner {
  11. require(msg.sender == owner);
  12. _;
  13. }
  14.  
  15. function transferOwnership(address newOwner) onlyOwner {
  16. owner = newOwner;
  17. }
  18. }
  19.  
  20. contract tokenRecipient {
  21.  
  22. uint256 public balance;
  23.  
  24. event receivedEther(address sender, uint amount);
  25. // event receivedTokens(address _from, uint256 _value, address _token, bytes _extraData);
  26.  
  27. // function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData){
  28. // // Token t = Token(_token);
  29. // require(t.transferFrom(_from, this, _value));
  30. // // receivedTokens(_from, _value, _token, _extraData);
  31. // }
  32.  
  33. function () payable {
  34.  
  35. receivedEther(msg.sender, msg.value);
  36. balance += msg.value;
  37. }
  38. }
  39.  
  40. // contract Token {
  41. // mapping (address => uint256) public balanceOf;
  42. // function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
  43. // }
  44.  
  45. /**
  46. * The shareholder association contract itself
  47. */
  48. contract ShareholderOrg is owned, tokenRecipient {
  49.  
  50. uint public minimumQuorum;
  51. uint public debatingPeriodInMinutes;
  52. Proposal[] public proposals;
  53. uint public numProposals;
  54. // Token public sharesTokenAddress;
  55.  
  56.  
  57. event ProposalAdded(uint proposalID, address recipient, uint amount, string description);
  58. event Voted(uint proposalID, bool position, address voter);
  59. event ProposalTallied(uint proposalID, uint result, uint quorum, bool active);
  60. event ChangeOfRules(uint newMinimumQuorum, uint newDebatingPeriodInMinutes, address newSharesTokenAddress);
  61.  
  62. struct Proposal {
  63. address recipient;
  64. uint amount;
  65. string description;
  66. uint votingDeadline;
  67. bool executed;
  68. bool proposalPassed;
  69. uint numberOfVotes;
  70. bytes32 proposalHash;
  71. Vote[] votes;
  72. mapping (address => bool) voted;
  73. }
  74.  
  75. struct Vote {
  76. bool inSupport;
  77. address voter;
  78. }
  79.  
  80. // Modifier that allows only shareholders to vote and create new proposals
  81. modifier onlyShareholders {
  82. require(sharesTokenAddress.balanceOf(msg.sender) > 0);
  83. _;
  84. }
  85.  
  86. function withdrawProfit() onlyShareholders returns (bool success) {
  87.  
  88. }
  89.  
  90. /**
  91. * Constructor function
  92. *
  93. * First time setup
  94. */
  95. function ShareholderOrg(Token sharesAddress, uint minimumSharesToPassAVote, uint minutesForDebate) payable {
  96. changeVotingRules(sharesAddress, minimumSharesToPassAVote, minutesForDebate);
  97. }
  98.  
  99. /**
  100. * Change voting rules
  101. *
  102. * Make so that proposals need tobe discussed for at least `minutesForDebate/60` hours
  103. * and all voters combined must own more than `minimumSharesToPassAVote` shares of token `sharesAddress` to be executed
  104. *
  105. * @param sharesAddress token address
  106. * @param minimumSharesToPassAVote proposal can vote only if the sum of shares held by all voters exceed this number
  107. * @param minutesForDebate the minimum amount of delay between when a proposal is made and when it can be executed
  108. */
  109. function changeVotingRules(Token sharesAddress, uint minimumSharesToPassAVote, uint minutesForDebate) onlyOwner {
  110. sharesTokenAddress = Token(sharesAddress);
  111. if (minimumSharesToPassAVote == 0 ) minimumSharesToPassAVote = 1;
  112. minimumQuorum = minimumSharesToPassAVote;
  113. debatingPeriodInMinutes = minutesForDebate;
  114. ChangeOfRules(minimumQuorum, debatingPeriodInMinutes, sharesTokenAddress);
  115. }
  116.  
  117.  
  118.  
  119. }
Add Comment
Please, Sign In to add comment