0

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?

  • Ask yourself what is the return-value type of function ownerOf. – goodvibration Aug 9 at 7:46
  • address does that mean i need casting? – bbusdriver Aug 9 at 7:56
  • Yes it does..... – goodvibration Aug 9 at 11:49
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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