0

I'm writing Decentralised Application. I've added function vote() an function changeName(). After that my code can't compile on wallet.ethereum.org. Though remix.ethereum.org shows no mistakes.

pragma solidity ^0.4.19;

contract SimpleDAO {

  string public name;   
  string public symbol;  
  uint8 public decimals;

  uint256 public totalSupply; 

   mapping (address => uint256) public balanceOf; 

   mapping (address => mapping (address => uint256)) public allowance;  

    uint8 public minVotes = 6;
   string public proposalName;
   bool public voteActive = false;
  struct Votes{
     uint256 current;
     uint numberOfVotes;
   }
   Votes public election;

   event Transfer(address from, address to, uint256 value);

   event Approve(address from, address to, uint256 value);

    function SimpleDao() public { 

     decimals = 0;

    totalSupply = 1000000 * (10 ** uint256(decimals));
    balanceOf[msg.sender] = totalSupply;

    name = "SimpleDAO";

    symbol = "tDAO"; 
  }

 function  _transfer (address _from, address _to, uint256 _value) internal{
  require (_to != 0x0);
 require(balanceOf[_from] >= _value);
 require(balanceOf[_to] + _value >= balanceOf[_to]);
 balanceOf[_from] -= _value;
 balanceOf[_to] += _value;
  Transfer(_from,_to,_value);
}
 function transfer(address _to, uint256 _value) public {
   _transfer(msg.sender, _to, _value);
 }

   function transferFrom (address _from, address _to, uint256 _value) public { 

  require(_value <= allowance[_from][_to]);  
   allowance[_from][_to] -= _value;  

  _transfer(_from, _to, _value);
}
   function approve(address _to, uint256 _value) public{

   allowance[msg.sender][_to] = _value; 

   Approve(msg.sender, _to, _value);
 }  

  function newName (string _proposalName)  public{
     require(!voteActive);
     proposalName = _proposalName;
     voteActive = true;
  }
  function vote(bool _vote) public {
       require(voteActive);
       if (_vote) {
         election.current += uint256(balanceOf[msg.sender]);            
         }
       else {
         election.current      -= uint256(balanceOf[msg.sender]);
        } 
         election.numberOfVotes += uint256(balanceOf[msg.sender]);  
      }
   function changeName() public{
     require(voteActive);
    require(election.numberOfVotes >= minVotes);
     if (election.current > 0) {
         name = proposalName;  
      }    
       election.numberOfVotes = 0; 
       election.current = 0;
       voteActive = false;
  }
}
  • Hi there. Are there any compiler errors? How do you know it won't compile? – Richard Horrocks Feb 16 '18 at 8:32
  • my code can't compile on wallet.ethereum.org. – Anatoly Feb 16 '18 at 12:44
0

The answer is that it should be deployed in mist, not on wallet.ethereum.org

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.