1
pragma solidity ^0.6.0;

contract Campaign {
    Request[] public requests;
    address  public  manager;
    uint public minimumConstribution;
    mapping(address => bool ) public approvers;
    uint public approversCount;

    constructor(uint minimum) public {
        manager = msg.sender;
        minimumConstribution = minimum;
    }

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

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



    function constribute() public payable {
        require(msg.value > minimumConstribution);

        approvers[msg.sender] = true;

        approversCount++;
    }

    function createRequest(string memory description, uint value, address 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);  
   //THis above line shows error   //.tranfer method not working in compiler version 0.6.0.//



        request.complete = true;


    }

}

1 Answer 1

1

If you wish to send Ethers to an address it has to be of type address payable. Therefore you have to change the struct structure and your function parameter type to be address payable instead of just address.

So in the struct you should have this line:

address payable recipient;

And in the function signature this line:

function createRequest(string memory description, uint value, address payable recipient) public restricted {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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