Nat Serrano
Nat Serrano

Reputation: 636

Type address is not implicitly convertible to expected type address payable. owner = msg.sender

I'm getting this error when compiling. I know it's related to v8 and I need to make them payable, and I did but still doesn't work. can a good samaritan help?

contract FundMe {
    
    mapping(address =>uint256) public addressToAmountFunded;
    
    address payable[] public funders;
    
    address payable public owner;
    
    constructor() public {
        owner = msg.sender; //LINE WITH ERROR
    }
    
    function fund() public payable {
        uint256 minimumUSD = 50 * 10 ** 18; 
        
        require(getConversionRate(msg.value) >= minimumUSD, "you need to spend more ETH my friend");
        
        addressToAmountFunded[msg.sender] += msg.value;
        
        funders.push(msg.sender); //ERROR AS WELL
        
    }

Upvotes: 10

Views: 11694

Answers (1)

Peter
Peter

Reputation: 898

Try wrapping the addresses like bellow:

payable(msg.sender)

Upvotes: 31

Related Questions