Address.Transfer Payable – Address Payable Type Error in Solidity 0.5.x

address.transferpayablesolidity-0.5.x

Just upgraded truffle to version 5 and having a problem with this new address payable type.

contract Test {
  ERC721Full public tokenAddress;

  constructor(address _address) public {
    tokenAddress = ERC721Full (_address);
  }

  function sendToOwner(...) public payable {
    address payable owner = tokenAddress.ownerOf(_tokenId);
    owner.transfer(msg.value);
  }
}

So I'm trying to send ether to owner account, but I'm getting

TypeError: Type address is not implicitly convertible to expected type address payable.

How to fix this?

Best Answer

tokenAddress.ownerOf() probably returns an address, not address payable. See this thread for a way to do that: Convert contract to payable address

Related Topic