I have this withdrawal function but an error happens:

TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address". --> sd.sol:138:13: | 138 | msg.sender.transfer(withdrawAmount); | ^^^^^^^^^^^^^^^^^^^


function withdraw(uint withdrawAmount) public returns (uint remainingBal) {
    // Check enough balance available, otherwise just return balance
    if (withdrawAmount <= balances[msg.sender]) {
        balances[msg.sender] -= withdrawAmount;
    return balances[msg.sender];

I can send WEI for my contract, so it stores the WEI but I want to be able to withdraw them.

Link do contrato

  • 1
    What's the problem exactly? Since 0.8 msg.sender is not payable. To use with transfer or send it has to be converted to payable like this payable(msg.sender).transfer(1 gwei).
    – Ismael
    Commented May 9, 2021 at 2:48
  • @Ismael worked by doing what you put in, converting it to payable. Commented May 10, 2021 at 10:48

1 Answer 1


The problem was on the line:


So I had to put msg.sender as payable.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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