0

pragma solidity ^0.5.11;

contract CampaignFactory {
    address[] public deployedCampaigns;

    function createCampaign(uint minimum) public {
        address newCampaignAddress = new Campaign(minimum, msg.sender);
        deployedCampaigns.push(newCampaignAddress);
    }

    function getDeployedCampaing() public view returns(address[]memory) {
        return deployedCampaigns;
    }
}
contract Campaign {

    struct Request {
        string description;
        uint value;
        address payable recipient;
        bool complete;
        uint approvalCount;
        mapping(address => bool) approvals;
    }

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

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

    constructor(uint 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, uint value, address payable recipient) public restricted {
        Request memory newRequest = Request({
            description: description,
            value: value,
            recipient: recipient,
            complete: false,
            approvalCount: 0
        });

        requests.push(newRequest);
    }

    function approveRequest(uint index) public {
        Request storage request = requests[index];

        require(approvers[msg.sender]);
        require(!request.approvals[msg.sender]);

        request.approvals[msg.sender] == true;
        request.approvalCount++;
    }

    function finalizeRequest(uint index) public restricted{
        Request storage request = requests[index];

        require(request.approvalCount > (approversCount / 2));
        require(!request.complete);

        request.recipient.transfer(request.value);
        request.complete = true;
    }
}

closed as unclear what you're asking by shane, alberto, Majd TL, Richard Horrocks, Ismael Sep 27 at 5:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • there is a error on line 7, – aybars dorman Sep 21 at 1:07
  • you didn't mention what the error message is, but I bet it's because you are assigning a Campaign object to an address variable. – Chan-Ho Suh Sep 21 at 1:22
  • right not thise error was solved , but ı have got new erros message when ı click minimum contribition output is like ; call to Campaign.minimumContribution errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information. – aybars dorman Sep 21 at 4:39
0

I assume the issue is on this line:

address newCampaignAddress = new Campaign(minimum, msg.sender);

newCampaignAddress is an address, while the right hand side of the assignment is not. It's a Campaign. As the error message indicates, Solidity will not implicitly cast from Campaign to address. You can, however, explicitly cast the value:

address newCampaignAddress = address(new Campaign(minimum, msg.sender));

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