0

I have written following Smart contract.

pragma solidity >=0.4.17;

contract factoryCampaign {

    Campaign[] public deployedCampaign;

    function createCampaign (uint256 minimumContribution) public {
        Campaign newCampaign = new Campaign(minimumContribution, msg.sender);
        deployedCampaign.push(newCampaign);
    }

    function getDeplyedCampaigns() public view returns(Campaign[] memory) {
        return deployedCampaign;        
    }
}

contract Campaign {

    struct Request {
        string description;
        uint256 value;
        address recipient;
        bool complete;
        uint256 approvalCount;
        mapping (address => bool) approvers;

    }
    address public manager;
    uint256 public minimumContribution;
    mapping(address=> bool) public approvers; 
    Request[] public requests;
    uint256 public approversCount;

    modifier restricted() {
        require (msg.sender == manager);
        _;
    }

     constructor (uint256 minimum, address creator) public {
         manager = creator;
         minimumContribution = minimum;
     }

     function contribute() public payable {
         require (msg.value > minimumContribution);
         approvers[msg.sender] = true;
         approversCount++;
     }

     function createRequest(string memory description, uint256 value, address recipient) public restricted {
         Request memory newRequest = Request({
             description: description,
             value: value,
             recipient: recipient,
             complete: false,
             approvalCount: 0
         });

         requests.push(newRequest);

     }

     function approveRequest(uint256 index) public {
         Request storage request = requests[index];
         require(approvers[msg.sender]);
         require(!request.approvers[msg.sender]);
         request.approvers[msg.sender] = true;
         request.approvalCount++;
     }

     function finalizeRequest(uint256 index) public payable {
         Request storage request = requests[index];
         require(!request.complete);
         require(request.approvalCount > (approversCount / 2));
         address payable recipient = address(uint160(request.recipient));
         recipient.transfer(request.value);
         request.complete = true;
     }

}

I am getting following error:

ParserError: Expected ';' but gor 'payable'

Error line seems to be:

address payable recipient = address(uint160(request.recipient));

Solidity version: 0.4.25

1
  • ParserError: Expected identifier but got 'payable' address payable private developerAccount_; ^-----^ – jomol jaison Apr 15 at 8:21
3

In Solidity version 0.4.25 there does not yet exist address payable - all addresses are just address. So you can either remove the payable keyword or upgrade your compiler to use version 0.5.x.

Looks like you took the code from some place which expects you to use version 0.5.x and not 0.4.25.

2
  • I tried to remove payable. But then I got something like this: "send" and "transfer" are only available for objects of type "address payable", not "address". – Sagar Deshpande Mar 9 '19 at 13:25
  • It works just fine here if I just copypaste that in Remix, remove payable and change compiler to version 0.4.25. So I guess you are still using mixed versions in some way. – Lauri Peltonen Mar 9 '19 at 14:32

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.