Solidity Remix – Troubleshooting Address Payable Not Working Issues

ethereum-wallet-dappremixsolidity

I'm working with solidity tutorial and the instructor write some code to send(withdraw) ether from the contract to address. but it's not working for me.it's shows an error like this

TypeError: Type address is not implicitly convertible to expected type address payable.
 --> sendingmoney.sol:15:9:
  |
15 |         address payable to = msg.sender;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is the code I wrote. The error is in line 15. Please helpenter image description here

Best Answer

Try this way:

function withdrawMoney() public {
    payable(msg.sender).transfer(this.getBalance());
}

Since last Solidity breaking changes they changed how you define payable addresses syntaxis.

Related Topic