3
Prapad

Escrow Contract - Type error: member "Transfer" not found

I am unable to compile the escrow contract as it gives an error at line 39 as follows:
– Type error: member “Transfer” not found or not visible after argument-dependent lookup in address. I am using Solidity version 0.5.1. See below.

pragma solidity ^0.5.1;

contract Escrow {
    enum State {AWAITING_PAYMENT, AWAITING_DELIVERY, COMPLETE, REFUNDED}
    State public currentState;
    
    address public buyer;
    address public seller;
    address public arbiter;
    
    modifier buyerOnly() {
        require (msg.sender == buyer || msg.sender == arbiter);
        _;
    }
    
    modifier sellerOnly () {
        require (msg.sender == seller || msg.sender == arbiter);
        _;
    }
    
    modifier inState (State expectedState) {
        require (currentState == expectedState);
        _;
    }
    
    constructor (address _buyer, address _seller, address _arbiter) public {
        buyer = _buyer;
        seller = _seller;
        arbiter = _arbiter;
    }
    
    function sendPayment() public payable buyerOnly inState (State.AWAITING_PAYMENT) {

        currentState = State.AWAITING_DELIVERY;
    }
    
    function confirmDelivery() public payable buyerOnly inState (State.AWAITING_DELIVERY) {
        currentState = State.COMPLETE;
        seller.transfer (address(this).balance);
    }
    
    function refundBuyer () public payable sellerOnly inState (State.AWAITING_DELIVERY) {
        currentState = State.REFUNDED;
        buyer.transfer (address (this).balance);
    }
}

Best answer

k_lodrick@hotmail.com
The explanation being that, for an account to send either it must be defined as payable.

Answers

  1. 3
    k_lodrick@hotmail.com
    try
        address payable public buyer;
        address payable public  seller;
        address payable public arbiter;
    and 
        constructor(address payable   _buyer, address  payable _seller, address payable _arbiter) public{
    Not sure if this is the correct thing to do, setting the addresses as payable. hopfully a lecturer can respond to you
  2. 3
    Prapad
    That worked, many thanks! I had made it as msg.sender, but was unsure as to the buyer and seller confusion, when using msg.sender. The address payable public buyer, seller etc. is cleaner. Thanks again!